The vast majority of these changes are in Linux specific code.
They are the result of not having an automated style checker to
validate the code when it was originally written. Others were
caused when the common code was slightly adjusted for Linux.
This patch contains no functional changes. It only refreshes
the code to conform to style guide.
Everyone submitting patches for inclusion upstream should now
run 'make checkstyle' and resolve any warning prior to opening
a pull request. The automated builders have been updated to
fail a build if when 'make checkstyle' detects an issue.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1821
len = strlen(cwd);
/* Do not add one when cwd already ends in a trailing '/' */
- if (!strncmp(cwd, dataset, len))
+ if (strncmp(cwd, dataset, len) == 0)
return (dataset + len + (cwd[len-1] != '/'));
return (dataset);
* done until zfs is added to the default selinux policy configuration
* as a known filesystem type which supports xattrs.
*/
- if (is_selinux_enabled() && !(zfsflags & ZS_NOCONTEXT)) {
- (void) strlcat(mntopts, ",context=\"system_u:"
- "object_r:file_t:s0\"", sizeof (mntopts));
- (void) strlcat(mtabopt, ",context=\"system_u:"
- "object_r:file_t:s0\"", sizeof (mtabopt));
+ if (is_selinux_enabled() && !(zfsflags & ZS_NOCONTEXT)) {
+ (void) strlcat(mntopts, ",context=\"system_u:"
+ "object_r:file_t:s0\"", sizeof (mntopts));
+ (void) strlcat(mtabopt, ",context=\"system_u:"
+ "object_r:file_t:s0\"", sizeof (mtabopt));
}
#endif /* HAVE_LIBSELINUX */
* using zfs as your root file system both rc.sysinit/umountroot and
* systemd depend on 'mount -o remount <mountpoint>' to work.
*/
- if (zfsutil && !strcmp(legacy, ZFS_MOUNTPOINT_LEGACY)) {
+ if (zfsutil && (strcmp(legacy, ZFS_MOUNTPOINT_LEGACY) == 0)) {
(void) fprintf(stderr, gettext(
"filesystem '%s' cannot be mounted using 'zfs mount'.\n"
"Use 'zfs set mountpoint=%s' or 'mount -t zfs %s %s'.\n"
"See zfs(8) for more information.\n"),
- dataset, mntpoint, dataset, mntpoint);
+ dataset, mntpoint, dataset, mntpoint);
return (MOUNT_USAGE);
}
(void) fprintf(stderr, " -t <txg> -- highest txg to use when "
"searching for uberblocks\n");
(void) fprintf(stderr, " -M <number of inflight I/Os> -- "
- "specify the maximum number of checksumming I/Os [default is 200]\n");
+ "specify the maximum number of checksumming I/Os "
+ "[default is 200]\n");
(void) fprintf(stderr, "Specify an option more than once (e.g. -bb) "
"to make only that option verbose\n");
(void) fprintf(stderr, "Default is to dump everything non-verbosely\n");
dle = AVL_NEXT(&dl->dl_tree, dle)) {
if (dump_opt['d'] >= 5) {
char buf[128];
- (void) snprintf(buf, sizeof (buf), "mintxg %llu -> obj %llu",
+ (void) snprintf(buf, sizeof (buf),
+ "mintxg %llu -> obj %llu",
(longlong_t)dle->dle_mintxg,
(longlong_t)dle->dle_bpobj.bpo_object);
(void) printf("\t\t%s = ", nvpair_name(elem));
nvpair_value_byte_array(elem, &value, &cnt);
- for (idx = 0 ; idx < cnt ; ++idx) {
+ for (idx = 0; idx < cnt; ++idx) {
if (isprint(value[idx]))
(void) putchar(value[idx]);
else
* it's not part of any space map) is a double allocation,
* reference to a freed block, or an unclaimed log block.
*/
- bzero(&zcb, sizeof(zdb_cb_t));
+ bzero(&zcb, sizeof (zdb_cb_t));
zdb_leak_init(spa, &zcb);
/*
} else if (psc->sc_prop == ZFS_PROP_NAME) {
lvalid = rvalid = B_TRUE;
- (void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf));
- (void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf));
+ (void) strlcpy(lbuf, zfs_get_name(l), sizeof (lbuf));
+ (void) strlcpy(rbuf, zfs_get_name(r), sizeof (rbuf));
lstr = lbuf;
rstr = rbuf;
if (pl->pl_prop == ZFS_PROP_NAME) {
(void) strlcpy(property, zfs_get_name(zhp),
- sizeof(property));
+ sizeof (property));
propstr = property;
right_justify = zfs_prop_align_right(pl->pl_prop);
} else if (pl->pl_prop != ZPROP_INVAL) {
if (zfs_prop_get(zhp, pl->pl_prop, property,
sizeof (property), NULL, NULL, 0,
- cb->cb_literal) != 0)
+ cb->cb_literal) != 0)
propstr = "-";
else
propstr = property;
-/*****************************************************************************\
+/*
* ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space.
*
* You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
#ifndef _ZPIOS_H
-#define _ZPIOS_H
+#define _ZPIOS_H
#include <zpios-ctl.h>
-#define VERSION_SIZE 64
+#define VERSION_SIZE 64
/* Regular expressions */
-#define REGEX_NUMBERS "^[0-9]*[0-9]$"
-#define REGEX_NUMBERS_COMMA "^([0-9]+,)*[0-9]+$"
-#define REGEX_SIZE "^[0-9][0-9]*[kmgt]$"
-#define REGEX_SIZE_COMMA "^([0-9][0-9]*[kmgt]+,)*[0-9][0-9]*[kmgt]$"
+#define REGEX_NUMBERS "^[0-9]*[0-9]$"
+#define REGEX_NUMBERS_COMMA "^([0-9]+,)*[0-9]+$"
+#define REGEX_SIZE "^[0-9][0-9]*[kmgt]$"
+#define REGEX_SIZE_COMMA "^([0-9][0-9]*[kmgt]+,)*[0-9][0-9]*[kmgt]$"
/* Flags for low, high, incr */
-#define FLAG_SET 0x01
-#define FLAG_LOW 0x02
-#define FLAG_HIGH 0x04
-#define FLAG_INCR 0x08
+#define FLAG_SET 0x01
+#define FLAG_LOW 0x02
+#define FLAG_HIGH 0x04
+#define FLAG_INCR 0x08
-#define TRUE 1
-#define FALSE 0
+#define TRUE 1
+#define FALSE 0
-#define KB (1024)
-#define MB (KB * 1024)
-#define GB (MB * 1024)
-#define TB (GB * 1024)
+#define KB (1024)
+#define MB (KB * 1024)
+#define GB (MB * 1024)
+#define TB (GB * 1024)
-#define KMGT_SIZE 16
+#define KMGT_SIZE 16
-/* All offsets, sizes and counts can be passed to the application in
+/*
+ * All offsets, sizes and counts can be passed to the application in
* multiple ways.
* 1. a value (stored in val[0], val_count will be 1)
* 2. a comma separated list of values (stored in val[], using val_count)
* 3. a range and block sizes, low, high, factor (val_count must be 0)
*/
typedef struct pios_range_repeat {
- uint64_t val[32]; /* Comma sep array, or low, high, inc */
- uint64_t val_count; /* Num of values */
+ uint64_t val[32]; /* Comma sep array, or low, high, inc */
+ uint64_t val_count; /* Num of values */
uint64_t val_low;
uint64_t val_high;
uint64_t val_inc_perc;
- uint64_t next_val; /* Used for multiple runs in get_next() */
+ uint64_t next_val; /* For multiple runs in get_next() */
} range_repeat_t;
typedef struct cmd_args {
- range_repeat_t T; /* Thread count */
- range_repeat_t N; /* Region count */
- range_repeat_t O; /* Offset count */
- range_repeat_t C; /* Chunksize */
- range_repeat_t S; /* Regionsize */
-
- const char *pool; /* Pool */
- const char *name; /* Name */
- uint32_t flags; /* Flags */
- uint32_t io_type; /* DMUIO only */
- uint32_t verbose; /* Verbose */
- uint32_t human_readable; /* Human readable output */
-
- uint64_t regionnoise; /* Region noise */
- uint64_t chunknoise; /* Chunk noise */
- uint64_t thread_delay; /* Thread delay */
-
- char pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
- char post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
- char log[ZPIOS_PATH_SIZE]; /* Requested log dir */
+ range_repeat_t T; /* Thread count */
+ range_repeat_t N; /* Region count */
+ range_repeat_t O; /* Offset count */
+ range_repeat_t C; /* Chunksize */
+ range_repeat_t S; /* Regionsize */
+
+ const char *pool; /* Pool */
+ const char *name; /* Name */
+ uint32_t flags; /* Flags */
+ uint32_t io_type; /* DMUIO only */
+ uint32_t verbose; /* Verbose */
+ uint32_t human_readable; /* Human readable output */
+
+ uint64_t regionnoise; /* Region noise */
+ uint64_t chunknoise; /* Chunk noise */
+ uint64_t thread_delay; /* Thread delay */
+
+ char pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
+ char post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
+ char log[ZPIOS_PATH_SIZE]; /* Requested log dir */
/* Control */
int current_id;
} cmd_args_t;
int set_count(char *pattern1, char *pattern2, range_repeat_t *range,
- char *optarg, uint32_t *flags, char *arg);
+ char *optarg, uint32_t *flags, char *arg);
int set_lhi(char *pattern, range_repeat_t *range, char *optarg,
- int flag, uint32_t *flag_thread, char *arg);
+ int flag, uint32_t *flag_thread, char *arg);
int set_noise(uint64_t *noise, char *optarg, char *arg);
int set_load_params(cmd_args_t *args, char *optarg);
int check_mutual_exclusive_command_lines(uint32_t flag, char *arg);
-/*****************************************************************************\
+/*
* ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel
- * against ZFS while still being flexibly controled from user space.
+ * against ZFS while still being flexibly controlled from user space.
*
* Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
*
* You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include "zpios.h"
-static const char short_opt[] = "t:l:h:e:n:i:j:k:o:m:q:r:c:a:b:g:s:A:B:C:"
- "L:p:M:xP:R:G:I:N:T:VzOfHv?";
+static const char short_opt[] =
+ "t:l:h:e:n:i:j:k:o:m:q:r:c:a:b:g:s:A:B:C:"
+ "L:p:M:xP:R:G:I:N:T:VzOfHv?";
static const struct option long_opt[] = {
- {"threadcount", required_argument, 0, 't' },
- {"threadcount_low", required_argument, 0, 'l' },
- {"threadcount_high", required_argument, 0, 'h' },
- {"threadcount_incr", required_argument, 0, 'e' },
- {"regioncount", required_argument, 0, 'n' },
- {"regioncount_low", required_argument, 0, 'i' },
- {"regioncount_high", required_argument, 0, 'j' },
- {"regioncount_incr", required_argument, 0, 'k' },
- {"offset", required_argument, 0, 'o' },
- {"offset_low", required_argument, 0, 'm' },
- {"offset_high", required_argument, 0, 'q' },
- {"offset_incr", required_argument, 0, 'r' },
- {"chunksize", required_argument, 0, 'c' },
- {"chunksize_low", required_argument, 0, 'a' },
- {"chunksize_high", required_argument, 0, 'b' },
- {"chunksize_incr", required_argument, 0, 'g' },
- {"regionsize", required_argument, 0, 's' },
- {"regionsize_low", required_argument, 0, 'A' },
- {"regionsize_high", required_argument, 0, 'B' },
- {"regionsize_incr", required_argument, 0, 'C' },
- {"load", required_argument, 0, 'L' },
- {"pool", required_argument, 0, 'p' },
- {"name", required_argument, 0, 'M' },
- {"cleanup", no_argument, 0, 'x' },
- {"prerun", required_argument, 0, 'P' },
- {"postrun", required_argument, 0, 'R' },
- {"log", required_argument, 0, 'G' },
- {"regionnoise", required_argument, 0, 'I' },
- {"chunknoise", required_argument, 0, 'N' },
- {"threaddelay", required_argument, 0, 'T' },
- {"verify", no_argument, 0, 'V' },
- {"zerocopy", no_argument, 0, 'z' },
- {"nowait", no_argument, 0, 'O' },
- {"noprefetch", no_argument, 0, 'f' },
- {"human-readable", no_argument, 0, 'H' },
- {"verbose", no_argument, 0, 'v' },
- {"help", no_argument, 0, '?' },
- { 0, 0, 0, 0 },
+ {"threadcount", required_argument, 0, 't' },
+ {"threadcount_low", required_argument, 0, 'l' },
+ {"threadcount_high", required_argument, 0, 'h' },
+ {"threadcount_incr", required_argument, 0, 'e' },
+ {"regioncount", required_argument, 0, 'n' },
+ {"regioncount_low", required_argument, 0, 'i' },
+ {"regioncount_high", required_argument, 0, 'j' },
+ {"regioncount_incr", required_argument, 0, 'k' },
+ {"offset", required_argument, 0, 'o' },
+ {"offset_low", required_argument, 0, 'm' },
+ {"offset_high", required_argument, 0, 'q' },
+ {"offset_incr", required_argument, 0, 'r' },
+ {"chunksize", required_argument, 0, 'c' },
+ {"chunksize_low", required_argument, 0, 'a' },
+ {"chunksize_high", required_argument, 0, 'b' },
+ {"chunksize_incr", required_argument, 0, 'g' },
+ {"regionsize", required_argument, 0, 's' },
+ {"regionsize_low", required_argument, 0, 'A' },
+ {"regionsize_high", required_argument, 0, 'B' },
+ {"regionsize_incr", required_argument, 0, 'C' },
+ {"load", required_argument, 0, 'L' },
+ {"pool", required_argument, 0, 'p' },
+ {"name", required_argument, 0, 'M' },
+ {"cleanup", no_argument, 0, 'x' },
+ {"prerun", required_argument, 0, 'P' },
+ {"postrun", required_argument, 0, 'R' },
+ {"log", required_argument, 0, 'G' },
+ {"regionnoise", required_argument, 0, 'I' },
+ {"chunknoise", required_argument, 0, 'N' },
+ {"threaddelay", required_argument, 0, 'T' },
+ {"verify", no_argument, 0, 'V' },
+ {"zerocopy", no_argument, 0, 'z' },
+ {"nowait", no_argument, 0, 'O' },
+ {"noprefetch", no_argument, 0, 'f' },
+ {"human-readable", no_argument, 0, 'H' },
+ {"verbose", no_argument, 0, 'v' },
+ {"help", no_argument, 0, '?' },
+ { 0, 0, 0, 0 },
};
static int zpiosctl_fd; /* Control file descriptor */
{
fprintf(stderr, "Usage: zpios\n");
fprintf(stderr,
- " --threadcount -t =values\n"
- " --threadcount_low -l =value\n"
- " --threadcount_high -h =value\n"
- " --threadcount_incr -e =value\n"
- " --regioncount -n =values\n"
- " --regioncount_low -i =value\n"
- " --regioncount_high -j =value\n"
- " --regioncount_incr -k =value\n"
- " --offset -o =values\n"
- " --offset_low -m =value\n"
- " --offset_high -q =value\n"
- " --offset_incr -r =value\n"
- " --chunksize -c =values\n"
- " --chunksize_low -a =value\n"
- " --chunksize_high -b =value\n"
- " --chunksize_incr -g =value\n"
- " --regionsize -s =values\n"
- " --regionsize_low -A =value\n"
- " --regionsize_high -B =value\n"
- " --regionsize_incr -C =value\n"
- " --load -L =dmuio|ssf|fpp\n"
- " --pool -p =pool name\n"
+ " --threadcount -t =values\n"
+ " --threadcount_low -l =value\n"
+ " --threadcount_high -h =value\n"
+ " --threadcount_incr -e =value\n"
+ " --regioncount -n =values\n"
+ " --regioncount_low -i =value\n"
+ " --regioncount_high -j =value\n"
+ " --regioncount_incr -k =value\n"
+ " --offset -o =values\n"
+ " --offset_low -m =value\n"
+ " --offset_high -q =value\n"
+ " --offset_incr -r =value\n"
+ " --chunksize -c =values\n"
+ " --chunksize_low -a =value\n"
+ " --chunksize_high -b =value\n"
+ " --chunksize_incr -g =value\n"
+ " --regionsize -s =values\n"
+ " --regionsize_low -A =value\n"
+ " --regionsize_high -B =value\n"
+ " --regionsize_incr -C =value\n"
+ " --load -L =dmuio|ssf|fpp\n"
+ " --pool -p =pool name\n"
" --name -M =test name\n"
- " --cleanup -x\n"
- " --prerun -P =pre-command\n"
- " --postrun -R =post-command\n"
- " --log -G =log directory\n"
- " --regionnoise -I =shift\n"
- " --chunknoise -N =bytes\n"
- " --threaddelay -T =jiffies\n"
- " --verify -V\n"
- " --zerocopy -z\n"
- " --nowait -O\n"
+ " --cleanup -x\n"
+ " --prerun -P =pre-command\n"
+ " --postrun -R =post-command\n"
+ " --log -G =log directory\n"
+ " --regionnoise -I =shift\n"
+ " --chunknoise -N =bytes\n"
+ " --threaddelay -T =jiffies\n"
+ " --verify -V\n"
+ " --zerocopy -z\n"
+ " --nowait -O\n"
" --noprefetch -f\n"
- " --human-readable -H\n"
- " --verbose -v =increase verbosity\n"
- " --help -? =this help\n\n");
+ " --human-readable -H\n"
+ " --verbose -v =increase verbosity\n"
+ " --help -? =this help\n\n");
- return 0;
+ return (0);
}
static void args_fini(cmd_args_t *args)
if (argc == 1) {
usage();
- return (cmd_args_t *)NULL;
+ return ((cmd_args_t *)NULL);
}
/* Configure and populate the args structures */
- args = malloc(sizeof(*args));
+ args = malloc(sizeof (*args));
if (args == NULL)
- return NULL;
+ return (NULL);
- memset(args, 0, sizeof(*args));
+ memset(args, 0, sizeof (*args));
- while ((c=getopt_long(argc, argv, short_opt, long_opt, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, short_opt, long_opt, NULL)) != -1) {
rc = 0;
switch (c) {
case 't': /* --thread count */
- rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA,
- &args->T, optarg, &fl_th, "threadcount");
+ rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA,
+ &args->T, optarg, &fl_th, "threadcount");
break;
case 'l': /* --threadcount_low */
rc = set_lhi(REGEX_NUMBERS, &args->T, optarg,
- FLAG_LOW, &fl_th, "threadcount_low");
+ FLAG_LOW, &fl_th, "threadcount_low");
break;
case 'h': /* --threadcount_high */
rc = set_lhi(REGEX_NUMBERS, &args->T, optarg,
- FLAG_HIGH, &fl_th, "threadcount_high");
+ FLAG_HIGH, &fl_th, "threadcount_high");
break;
case 'e': /* --threadcount_inc */
rc = set_lhi(REGEX_NUMBERS, &args->T, optarg,
- FLAG_INCR, &fl_th, "threadcount_incr");
+ FLAG_INCR, &fl_th, "threadcount_incr");
break;
case 'n': /* --regioncount */
rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA,
- &args->N, optarg, &fl_rc, "regioncount");
+ &args->N, optarg, &fl_rc, "regioncount");
break;
case 'i': /* --regioncount_low */
rc = set_lhi(REGEX_NUMBERS, &args->N, optarg,
- FLAG_LOW, &fl_rc, "regioncount_low");
+ FLAG_LOW, &fl_rc, "regioncount_low");
break;
case 'j': /* --regioncount_high */
rc = set_lhi(REGEX_NUMBERS, &args->N, optarg,
- FLAG_HIGH, &fl_rc, "regioncount_high");
+ FLAG_HIGH, &fl_rc, "regioncount_high");
break;
case 'k': /* --regioncount_inc */
rc = set_lhi(REGEX_NUMBERS, &args->N, optarg,
- FLAG_INCR, &fl_rc, "regioncount_incr");
+ FLAG_INCR, &fl_rc, "regioncount_incr");
break;
case 'o': /* --offset */
rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA,
- &args->O, optarg, &fl_of, "offset");
+ &args->O, optarg, &fl_of, "offset");
break;
case 'm': /* --offset_low */
rc = set_lhi(REGEX_SIZE, &args->O, optarg,
- FLAG_LOW, &fl_of, "offset_low");
+ FLAG_LOW, &fl_of, "offset_low");
break;
case 'q': /* --offset_high */
rc = set_lhi(REGEX_SIZE, &args->O, optarg,
- FLAG_HIGH, &fl_of, "offset_high");
+ FLAG_HIGH, &fl_of, "offset_high");
break;
case 'r': /* --offset_inc */
rc = set_lhi(REGEX_NUMBERS, &args->O, optarg,
- FLAG_INCR, &fl_of, "offset_incr");
+ FLAG_INCR, &fl_of, "offset_incr");
break;
case 'c': /* --chunksize */
rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA,
- &args->C, optarg, &fl_cs, "chunksize");
+ &args->C, optarg, &fl_cs, "chunksize");
break;
case 'a': /* --chunksize_low */
rc = set_lhi(REGEX_SIZE, &args->C, optarg,
- FLAG_LOW, &fl_cs, "chunksize_low");
+ FLAG_LOW, &fl_cs, "chunksize_low");
break;
case 'b': /* --chunksize_high */
rc = set_lhi(REGEX_SIZE, &args->C, optarg,
- FLAG_HIGH, &fl_cs, "chunksize_high");
+ FLAG_HIGH, &fl_cs, "chunksize_high");
break;
case 'g': /* --chunksize_inc */
rc = set_lhi(REGEX_NUMBERS, &args->C, optarg,
- FLAG_INCR, &fl_cs, "chunksize_incr");
+ FLAG_INCR, &fl_cs, "chunksize_incr");
break;
case 's': /* --regionsize */
rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA,
- &args->S, optarg, &fl_rs, "regionsize");
+ &args->S, optarg, &fl_rs, "regionsize");
break;
case 'A': /* --regionsize_low */
rc = set_lhi(REGEX_SIZE, &args->S, optarg,
- FLAG_LOW, &fl_rs, "regionsize_low");
+ FLAG_LOW, &fl_rs, "regionsize_low");
break;
case 'B': /* --regionsize_high */
rc = set_lhi(REGEX_SIZE, &args->S, optarg,
- FLAG_HIGH, &fl_rs, "regionsize_high");
+ FLAG_HIGH, &fl_rs, "regionsize_high");
break;
case 'C': /* --regionsize_inc */
rc = set_lhi(REGEX_NUMBERS, &args->S, optarg,
- FLAG_INCR, &fl_rs, "regionsize_incr");
+ FLAG_INCR, &fl_rs, "regionsize_incr");
break;
case 'L': /* --load */
rc = set_load_params(args, optarg);
strncpy(args->log, optarg, ZPIOS_PATH_SIZE - 1);
break;
case 'I': /* --regionnoise */
- rc = set_noise(&args->regionnoise, optarg, "regionnoise");
+ rc = set_noise(&args->regionnoise, optarg,
+ "regionnoise");
break;
case 'N': /* --chunknoise */
rc = set_noise(&args->chunknoise, optarg, "chunknoise");
break;
case 'T': /* --threaddelay */
- rc = set_noise(&args->thread_delay, optarg, "threaddelay");
+ rc = set_noise(&args->thread_delay, optarg,
+ "threaddelay");
break;
case 'V': /* --verify */
args->flags |= DMU_VERIFY;
rc = 1;
break;
default:
- fprintf(stderr,"Unknown option '%s'\n",argv[optind-1]);
+ fprintf(stderr, "Unknown option '%s'\n",
+ argv[optind - 1]);
rc = EINVAL;
break;
}
if (rc) {
usage();
args_fini(args);
- return NULL;
+ return (NULL);
}
}
fprintf(stderr, "Error: Pool not specificed\n");
usage();
args_fini(args);
- return NULL;
+ return (NULL);
}
if ((args->flags & (DMU_WRITE_ZC | DMU_READ_ZC)) &&
(args->flags & DMU_VERIFY)) {
- fprintf(stderr, "Error, --zerocopy incompatible --verify, "
- "used for performance analysis only\n");
+ fprintf(stderr, "Error, --zerocopy incompatible --verify, "
+ "used for performance analysis only\n");
usage();
args_fini(args);
- return NULL;
+ return (NULL);
}
- return args;
+ return (args);
}
static int
zpios_cfg_t cfg;
int rc;
- memset(&cfg, 0, sizeof(cfg));
+ memset(&cfg, 0, sizeof (cfg));
cfg.cfg_magic = ZPIOS_CFG_MAGIC;
- cfg.cfg_cmd = ZPIOS_CFG_BUFFER_CLEAR;
+ cfg.cfg_cmd = ZPIOS_CFG_BUFFER_CLEAR;
cfg.cfg_arg1 = 0;
rc = ioctl(zpiosctl_fd, ZPIOS_CFG, &cfg);
if (rc)
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
- (unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno);
+ (unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno);
lseek(zpiosctl_fd, 0, SEEK_SET);
- return rc;
+ return (rc);
}
/* Passing a size of zero simply results in querying the current size */
zpios_cfg_t cfg;
int rc;
- memset(&cfg, 0, sizeof(cfg));
+ memset(&cfg, 0, sizeof (cfg));
cfg.cfg_magic = ZPIOS_CFG_MAGIC;
- cfg.cfg_cmd = ZPIOS_CFG_BUFFER_SIZE;
+ cfg.cfg_cmd = ZPIOS_CFG_BUFFER_SIZE;
cfg.cfg_arg1 = size;
rc = ioctl(zpiosctl_fd, ZPIOS_CFG, &cfg);
if (rc) {
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
- (unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno);
- return rc;
+ (unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno);
+ return (rc);
}
- return cfg.cfg_rc1;
+ return (cfg.cfg_rc1);
}
static void
if (zpiosctl_fd != -1) {
if (close(zpiosctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n",
- ZPIOS_DEV, errno);
+ ZPIOS_DEV, errno);
}
}
}
zpiosctl_fd = open(ZPIOS_DEV, O_RDONLY);
if (zpiosctl_fd == -1) {
fprintf(stderr, "Unable to open %s: %d\n"
- "Is the zpios module loaded?\n", ZPIOS_DEV, errno);
+ "Is the zpios module loaded?\n", ZPIOS_DEV, errno);
rc = errno;
goto error;
}
}
memset(zpios_buffer, 0, zpios_buffer_size);
- return 0;
+ return (0);
error:
if (zpiosctl_fd != -1) {
if (close(zpiosctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n",
- ZPIOS_DEV, errno);
+ ZPIOS_DEV, errno);
}
}
- return rc;
+ return (rc);
}
static int
/* if low, incr, high is given */
if (range->val_count == 0) {
*val = (range->val_low) +
- (range->val_low * range->next_val / 100);
+ (range->val_low * range->next_val / 100);
if (*val > range->val_high)
- return 0; /* No more values, limit exceeded */
+ return (0); /* No more values, limit exceeded */
if (!range->next_val)
range->next_val = range->val_inc_perc;
else
- range->next_val = range->next_val+range->val_inc_perc;
+ range->next_val = range->next_val + range->val_inc_perc;
- return 1; /* more values to come */
+ return (1); /* more values to come */
/* if only one val is given */
} else if (range->val_count == 1) {
if (range->next_val)
- return 0; /* No more values, we only have one */
+ return (0); /* No more values, we only have one */
*val = range->val[0];
range->next_val = 1;
- return 1; /* more values to come */
+ return (1); /* more values to come */
/* if comma separated values are given */
} else if (range->val_count > 1) {
if (range->next_val > range->val_count - 1)
- return 0; /* No more values, limit exceeded */
+ return (0); /* No more values, limit exceeded */
*val = range->val[range->next_val];
range->next_val++;
- return 1; /* more values to come */
+ return (1); /* more values to come */
}
- return 0;
+ return (0);
}
static int
run_one(cmd_args_t *args, uint32_t id, uint32_t T, uint32_t N,
- uint64_t C, uint64_t S, uint64_t O)
+ uint64_t C, uint64_t S, uint64_t O)
{
zpios_cmd_t *cmd;
- int rc, rc2, cmd_size;
+ int rc, rc2, cmd_size;
- dev_clear();
+ dev_clear();
- cmd_size = sizeof(zpios_cmd_t) + ((T + N + 1) * sizeof(zpios_stats_t));
- cmd = (zpios_cmd_t *)malloc(cmd_size);
- if (cmd == NULL)
- return ENOMEM;
+ cmd_size =
+ sizeof (zpios_cmd_t)
+ + ((T + N + 1) * sizeof (zpios_stats_t));
+ cmd = (zpios_cmd_t *)malloc(cmd_size);
+ if (cmd == NULL)
+ return (ENOMEM);
- memset(cmd, 0, cmd_size);
- cmd->cmd_magic = ZPIOS_CMD_MAGIC;
+ memset(cmd, 0, cmd_size);
+ cmd->cmd_magic = ZPIOS_CMD_MAGIC;
strncpy(cmd->cmd_pool, args->pool, ZPIOS_NAME_SIZE - 1);
strncpy(cmd->cmd_pre, args->pre, ZPIOS_PATH_SIZE - 1);
strncpy(cmd->cmd_post, args->post, ZPIOS_PATH_SIZE - 1);
strncpy(cmd->cmd_log, args->log, ZPIOS_PATH_SIZE - 1);
- cmd->cmd_id = id;
- cmd->cmd_chunk_size = C;
+ cmd->cmd_id = id;
+ cmd->cmd_chunk_size = C;
cmd->cmd_thread_count = T;
cmd->cmd_region_count = N;
- cmd->cmd_region_size = S;
- cmd->cmd_offset = O;
+ cmd->cmd_region_size = S;
+ cmd->cmd_offset = O;
cmd->cmd_region_noise = args->regionnoise;
- cmd->cmd_chunk_noise = args->chunknoise;
+ cmd->cmd_chunk_noise = args->chunknoise;
cmd->cmd_thread_delay = args->thread_delay;
- cmd->cmd_flags = args->flags;
- cmd->cmd_data_size = (T + N + 1) * sizeof(zpios_stats_t);
+ cmd->cmd_flags = args->flags;
+ cmd->cmd_data_size = (T + N + 1) * sizeof (zpios_stats_t);
- rc = ioctl(zpiosctl_fd, ZPIOS_CMD, cmd);
+ rc = ioctl(zpiosctl_fd, ZPIOS_CMD, cmd);
if (rc)
args->rc = errno;
print_stats(args, cmd);
- if (args->verbose) {
- rc2 = read(zpiosctl_fd, zpios_buffer, zpios_buffer_size - 1);
- if (rc2 < 0) {
- fprintf(stdout, "Error reading results: %d\n", rc2);
- } else if ((rc2 > 0) && (strlen(zpios_buffer) > 0)) {
- fprintf(stdout, "\n%s\n", zpios_buffer);
- fflush(stdout);
- }
- }
+ if (args->verbose) {
+ rc2 = read(zpiosctl_fd, zpios_buffer, zpios_buffer_size - 1);
+ if (rc2 < 0) {
+ fprintf(stdout, "Error reading results: %d\n", rc2);
+ } else if ((rc2 > 0) && (strlen(zpios_buffer) > 0)) {
+ fprintf(stdout, "\n%s\n", zpios_buffer);
+ fflush(stdout);
+ }
+ }
- free(cmd);
+ free(cmd);
- return rc;
+ return (rc);
}
static int
while (rc == 0 && get_next(&args->current_O, &args->O)) {
rc = run_one(args, args->current_id,
- args->current_T, args->current_N, args->current_C,
- args->current_S, args->current_O);
+ args->current_T, args->current_N, args->current_C,
+ args->current_S, args->current_O);
args->current_id++;
}
args->O.next_val = 0;
- return rc;
+ return (rc);
}
static int
int rc = 0;
while (rc == 0 && get_next((uint64_t *)&args->current_N, &args->N))
- rc = run_offsets(args);
+ rc = run_offsets(args);
args->N.next_val = 0;
- return rc;
+ return (rc);
}
static int
if (args->current_S < args->current_C) {
fprintf(stderr, "Error: in any run chunksize can "
"not be smaller than regionsize.\n");
- return EINVAL;
+ return (EINVAL);
}
rc = run_region_counts(args);
}
args->S.next_val = 0;
- return rc;
+ return (rc);
}
static int
int rc = 0;
while (rc == 0 && get_next(&args->current_C, &args->C)) {
- rc = run_region_sizes(args);
+ rc = run_region_sizes(args);
}
args->C.next_val = 0;
- return rc;
+ return (rc);
}
static int
while (rc == 0 && get_next((uint64_t *)&args->current_T, &args->T))
rc = run_chunk_sizes(args);
- return rc;
+ return (rc);
}
int
args_fini(args);
dev_fini();
- return rc;
+ return (rc);
}
-/*****************************************************************************\
+/*
* ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space.
*
* You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
#include <stdlib.h>
#include <stdio.h>
*val = strtoll(str, &endptr, 0);
if ((str == endptr) && (*val == 0))
- return EINVAL;
+ return (EINVAL);
switch (endptr[0]) {
case 'k': case 'K':
rc = EINVAL;
}
- return rc;
+ return (rc);
}
static char *
}
if (i >= 4)
- (void)snprintf(str, KMGT_SIZE-1, "inf");
+ (void) snprintf(str, KMGT_SIZE-1, "inf");
else
- (void)snprintf(str, KMGT_SIZE-1, "%lu%c", (unsigned long)val,
- (i == -1) ? '\0' : postfix[i]);
+ (void) snprintf(str, KMGT_SIZE-1, "%lu%c", (unsigned long)val,
+ (i == -1) ? '\0' : postfix[i]);
- return str;
+ return (str);
}
static char *
}
if (i >= 4)
- (void)snprintf(str, KMGT_SIZE-1, "inf");
+ (void) snprintf(str, KMGT_SIZE-1, "inf");
else
- (void)snprintf(str, KMGT_SIZE-1, "%.2f%c", val,
- (i == -1) ? '\0' : postfix[i]);
+ (void) snprintf(str, KMGT_SIZE-1, "%.2f%c", val,
+ (i == -1) ? '\0' : postfix[i]);
- return str;
+ return (str);
}
static char *
str[6] = (flags & DMU_WRITE_NOWAIT) ? 'O' : '-';
str[7] = '\0';
- return str;
+ return (str);
}
static int
rc = regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE);
if (rc) {
fprintf(stderr, "Error: Couldn't do regcomp, %d\n", rc);
- return rc;
+ return (rc);
}
rc = regexec(&re, string, (size_t) 0, NULL, 0);
regfree(&re);
- return rc;
+ return (rc);
}
/* fills the pios_range_repeat structure of comma separated values */
int rc, i = 0;
if ((rc = regex_match(optarg, pattern)))
- return rc;
+ return (rc);
cp = strdup(optarg);
if (cp == NULL)
- return ENOMEM;
+ return (ENOMEM);
do {
- /* STRTOK(3) Each subsequent call, with a null pointer as the
+ /*
+ * STRTOK(3) Each subsequent call, with a null pointer as the
* value of the * first argument, starts searching from the
* saved pointer and behaves as described above.
*/
kmgt_to_uint64(token[i], &range->val[i]);
free(cp);
- return 0;
+ return (0);
}
int
set_count(char *pattern1, char *pattern2, range_repeat_t *range,
- char *optarg, uint32_t *flags, char *arg)
+ char *optarg, uint32_t *flags, char *arg)
{
if (flags)
*flags |= FLAG_SET;
range->val_count = 1;
} else if (split_string(optarg, pattern2, range) < 0) {
fprintf(stderr, "Error: Incorrect pattern for %s, '%s'\n",
- arg, optarg);
- return EINVAL;
+ arg, optarg);
+ return (EINVAL);
}
- return 0;
+ return (0);
}
-/* validates the value with regular expression and sets low, high, incr
- * according to value at which flag will be set. Sets the flag after. */
+/*
+ * Validates the value with regular expression and sets low, high, incr
+ * according to value at which flag will be set. Sets the flag after.
+ */
int
set_lhi(char *pattern, range_repeat_t *range, char *optarg,
- int flag, uint32_t *flag_thread, char *arg)
+ int flag, uint32_t *flag_thread, char *arg)
{
int rc;
if ((rc = regex_match(optarg, pattern))) {
fprintf(stderr, "Error: Wrong pattern in %s, '%s'\n",
arg, optarg);
- return rc;
+ return (rc);
}
switch (flag) {
*flag_thread |= flag;
- return 0;
+ return (0);
}
int
kmgt_to_uint64(optarg, noise);
} else {
fprintf(stderr, "Error: Incorrect pattern for %s\n", arg);
- return EINVAL;
+ return (EINVAL);
}
- return 0;
+ return (0);
}
int
search = strdup(optarg);
if (search == NULL)
- return ENOMEM;
+ return (ENOMEM);
while ((param = strtok(search, comma)) != NULL) {
search = NULL;
free(search);
- return rc;
+ return (rc);
}
-/* checks the low, high, increment values against the single value for
+/*
+ * Checks the low, high, increment values against the single value for
* mutual exclusion, for e.g threadcount is mutually exclusive to
- * threadcount_low, ..._high, ..._incr */
+ * threadcount_low, ..._high, ..._incr
+ */
int
check_mutual_exclusive_command_lines(uint32_t flag, char *arg)
{
if ((flag & FLAG_SET) && (flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR))) {
fprintf(stderr, "Error: --%s can not be given with --%s_low, "
- "--%s_high or --%s_incr.\n", arg, arg, arg, arg);
- return 0;
+ "--%s_high or --%s_incr.\n", arg, arg, arg, arg);
+ return (0);
}
- if ((flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) && !(flag & FLAG_SET)){
+ if ((flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) && !(flag & FLAG_SET)) {
if (flag != (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) {
fprintf(stderr, "Error: One or more values missing "
- "from --%s_low, --%s_high, --%s_incr.\n",
- arg, arg, arg);
- return 0;
+ "from --%s_low, --%s_high, --%s_incr.\n",
+ arg, arg, arg);
+ return (0);
}
}
- return 1;
+ return (1);
}
void
print_stats_header(cmd_args_t *args)
{
if (args->verbose) {
- printf("status name id\tth-cnt\trg-cnt\trg-sz\t"
- "ch-sz\toffset\trg-no\tch-no\tth-dly\tflags\ttime\t"
- "cr-time\trm-time\twr-time\trd-time\twr-data\twr-ch\t"
- "wr-bw\trd-data\trd-ch\trd-bw\n");
- printf("------------------------------------------------"
- "------------------------------------------------"
- "------------------------------------------------"
- "----------------------------------------------\n");
+ printf(
+ "status name id\tth-cnt\trg-cnt\trg-sz\t"
+ "ch-sz\toffset\trg-no\tch-no\tth-dly\tflags\ttime\t"
+ "cr-time\trm-time\twr-time\trd-time\twr-data\twr-ch\t"
+ "wr-bw\trd-data\trd-ch\trd-bw\n");
+ printf(
+ "------------------------------------------------"
+ "------------------------------------------------"
+ "------------------------------------------------"
+ "----------------------------------------------\n");
} else {
- printf("status name id\t"
- "wr-data\twr-ch\twr-bw\t"
- "rd-data\trd-ch\trd-bw\n");
- printf("-----------------------------------------"
- "--------------------------------------\n");
+ printf(
+ "status name id\t"
+ "wr-data\twr-ch\twr-bw\t"
+ "rd-data\trd-ch\trd-bw\n");
+ printf(
+ "-----------------------------------------"
+ "--------------------------------------\n");
}
}
printf("PASS: ");
printf("%-12s", args->name ? args->name : ZPIOS_NAME);
- printf("%2u\t", cmd->cmd_id);
+ printf("%2u\t", cmd->cmd_id);
if (args->verbose) {
- printf("%u\t", cmd->cmd_thread_count);
- printf("%u\t", cmd->cmd_region_count);
- printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_size));
- printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_size));
- printf("%s\t", uint64_to_kmgt(str, cmd->cmd_offset));
- printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_noise));
- printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_noise));
- printf("%s\t", uint64_to_kmgt(str, cmd->cmd_thread_delay));
+ printf("%u\t", cmd->cmd_thread_count);
+ printf("%u\t", cmd->cmd_region_count);
+ printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_size));
+ printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_size));
+ printf("%s\t", uint64_to_kmgt(str, cmd->cmd_offset));
+ printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_noise));
+ printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_noise));
+ printf("%s\t", uint64_to_kmgt(str, cmd->cmd_thread_delay));
printf("%s\t", print_flags(str, cmd->cmd_flags));
}
printf("%.2f\t", rd_time);
}
- printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_data));
- printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_chunks));
+ printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_data));
+ printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_chunks));
printf("%s\t", kmgt_per_sec(str, summary_stats->wr_data, wr_time));
- printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_data));
- printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_chunks));
+ printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_data));
+ printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_chunks));
printf("%s\n", kmgt_per_sec(str, summary_stats->rd_data, rd_time));
fflush(stdout);
}
printf("PASS: ");
printf("%-12s", args->name ? args->name : ZPIOS_NAME);
- printf("%2u\t", cmd->cmd_id);
+ printf("%2u\t", cmd->cmd_id);
if (args->verbose) {
- printf("%u\t", cmd->cmd_thread_count);
- printf("%u\t", cmd->cmd_region_count);
- printf("%llu\t", (long long unsigned)cmd->cmd_region_size);
- printf("%llu\t", (long long unsigned)cmd->cmd_chunk_size);
- printf("%llu\t", (long long unsigned)cmd->cmd_offset);
- printf("%u\t", cmd->cmd_region_noise);
- printf("%u\t", cmd->cmd_chunk_noise);
- printf("%u\t", cmd->cmd_thread_delay);
+ printf("%u\t", cmd->cmd_thread_count);
+ printf("%u\t", cmd->cmd_region_count);
+ printf("%llu\t", (long long unsigned)cmd->cmd_region_size);
+ printf("%llu\t", (long long unsigned)cmd->cmd_chunk_size);
+ printf("%llu\t", (long long unsigned)cmd->cmd_offset);
+ printf("%u\t", cmd->cmd_region_noise);
+ printf("%u\t", cmd->cmd_chunk_noise);
+ printf("%u\t", cmd->cmd_thread_delay);
printf("0x%x\t", cmd->cmd_flags);
}
if (args->verbose) {
printf("%ld.%02ld\t",
- (long)summary_stats->total_time.delta.ts_sec,
- (long)summary_stats->total_time.delta.ts_nsec);
+ (long)summary_stats->total_time.delta.ts_sec,
+ (long)summary_stats->total_time.delta.ts_nsec);
printf("%ld.%02ld\t",
- (long)summary_stats->cr_time.delta.ts_sec,
- (long)summary_stats->cr_time.delta.ts_nsec);
+ (long)summary_stats->cr_time.delta.ts_sec,
+ (long)summary_stats->cr_time.delta.ts_nsec);
printf("%ld.%02ld\t",
- (long)summary_stats->rm_time.delta.ts_sec,
- (long)summary_stats->rm_time.delta.ts_nsec);
+ (long)summary_stats->rm_time.delta.ts_sec,
+ (long)summary_stats->rm_time.delta.ts_nsec);
printf("%ld.%02ld\t",
- (long)summary_stats->wr_time.delta.ts_sec,
- (long)summary_stats->wr_time.delta.ts_nsec);
+ (long)summary_stats->wr_time.delta.ts_sec,
+ (long)summary_stats->wr_time.delta.ts_nsec);
printf("%ld.%02ld\t",
- (long)summary_stats->rd_time.delta.ts_sec,
- (long)summary_stats->rd_time.delta.ts_nsec);
+ (long)summary_stats->rd_time.delta.ts_sec,
+ (long)summary_stats->rd_time.delta.ts_nsec);
}
- printf("%lld\t", (long long unsigned)summary_stats->wr_data);
- printf("%lld\t", (long long unsigned)summary_stats->wr_chunks);
+ printf("%lld\t", (long long unsigned)summary_stats->wr_data);
+ printf("%lld\t", (long long unsigned)summary_stats->wr_chunks);
printf("%.4f\t", (double)summary_stats->wr_data / wr_time);
- printf("%lld\t", (long long unsigned)summary_stats->rd_data);
- printf("%lld\t", (long long unsigned)summary_stats->rd_chunks);
+ printf("%lld\t", (long long unsigned)summary_stats->rd_data);
+ printf("%lld\t", (long long unsigned)summary_stats->rd_chunks);
printf("%.4f\n", (double)summary_stats->rd_data / rd_time);
fflush(stdout);
}
columns = 999;
}
- return columns;
+ return (columns);
}
int
}
(void) printf("%s [internal %s txg:%lld] %s", tbuf,
zfs_history_event_names[ievent],
- (long long int)fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG),
+ (longlong_t) fnvlist_lookup_uint64(
+ rec, ZPOOL_HIST_TXG),
fnvlist_lookup_string(rec, ZPOOL_HIST_INT_STR));
} else if (nvlist_exists(rec, ZPOOL_HIST_INT_NAME)) {
if (!cb->internal)
continue;
(void) printf("%s [txg:%lld] %s", tbuf,
- (long long int)fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG),
+ (longlong_t) fnvlist_lookup_uint64(
+ rec, ZPOOL_HIST_TXG),
fnvlist_lookup_string(rec, ZPOOL_HIST_INT_NAME));
if (nvlist_exists(rec, ZPOOL_HIST_DSNAME)) {
(void) printf(" %s (%llu)",
fnvlist_lookup_string(rec,
ZPOOL_HIST_DSNAME),
- (long long unsigned int)fnvlist_lookup_uint64(rec,
+ (u_longlong_t)fnvlist_lookup_uint64(rec,
ZPOOL_HIST_DSID));
}
(void) printf(" %s", fnvlist_lookup_string(rec,
verify(nvlist_lookup_int64_array(nvl, FM_EREPORT_TIME, &tv, &n) == 0);
memset(str, ' ', 32);
(void) ctime_r((const time_t *)&tv[0], ctime_str);
- (void) strncpy(str, ctime_str+4, 6); /* 'Jun 30' */
- (void) strncpy(str+7, ctime_str+20, 4); /* '1993' */
- (void) strncpy(str+12, ctime_str+11, 8); /* '21:49:08' */
- (void) sprintf(str+20, ".%09lld", (longlong_t)tv[1]);/* '.123456789' */
+ (void) strncpy(str, ctime_str+4, 6); /* 'Jun 30' */
+ (void) strncpy(str+7, ctime_str+20, 4); /* '1993' */
+ (void) strncpy(str+12, ctime_str+11, 8); /* '21:49:08' */
+ (void) sprintf(str+20, ".%09lld", (longlong_t)tv[1]); /* '.123456789' */
(void) printf(gettext("%s "), str);
verify(nvlist_lookup_string(nvl, FM_CLASS, &ptr) == 0);
printf(gettext("(%d embedded nvlists)\n"), nelem);
for (i = 0; i < nelem; i++) {
printf(gettext("%*s%s[%d] = %s\n"),
- depth, "", name, i, "(embedded nvlist)");
+ depth, "", name, i, "(embedded nvlist)");
zpool_do_events_nvprint(val[i], depth + 8);
printf(gettext("%*s(end %s[%i])\n"),
- depth, "", name, i);
+ depth, "", name, i);
}
printf(gettext("%*s(end %s)\n"), depth, "", name);
}
(void) nvpair_value_int64_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- printf(gettext("0x%llx "), (u_longlong_t)val[i]);
+ printf(gettext("0x%llx "),
+ (u_longlong_t)val[i]);
break;
}
(void) nvpair_value_uint64_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- printf(gettext("0x%llx "), (u_longlong_t)val[i]);
+ printf(gettext("0x%llx "),
+ (u_longlong_t)val[i]);
break;
}
nvlist_t *nvl;
int cleanup_fd, ret, dropped;
- cleanup_fd = open(ZFS_DEV, O_RDWR);
- VERIFY(cleanup_fd >= 0);
+ cleanup_fd = open(ZFS_DEV, O_RDWR);
+ VERIFY(cleanup_fd >= 0);
if (!opts->scripted)
(void) printf(gettext("%-30s %s\n"), "TIME", "CLASS");
nvlist_free(nvl);
}
- VERIFY(0 == close(cleanup_fd));
+ VERIFY(0 == close(cleanup_fd));
return (ret);
}
else
ret = zpool_do_events_next(&opts);
- return ret;
+ return (ret);
}
static int
/*
* Special case '-?'
*/
- if ((strcmp(cmdname, "-?") == 0) ||
- strcmp(cmdname, "--help") == 0)
+ if ((strcmp(cmdname, "-?") == 0) || strcmp(cmdname, "--help") == 0)
usage(B_TRUE);
if ((g_zfs = libzfs_init()) == NULL)
*/
nvlist_t *make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force,
- int check_rep, boolean_t replacing, boolean_t dryrun, int argc, char **argv);
+ int check_rep, boolean_t replacing, boolean_t dryrun, int argc,
+ char **argv);
nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname,
nvlist_t *props, splitflags_t flags, int argc, char **argv);
#ifdef HAVE_LIBBLKID
#include <blkid/blkid.h>
#else
-#define blkid_cache void *
+#define blkid_cache void *
#endif /* HAVE_LIBBLKID */
#include "zpool_util.h"
{"ATA SAMSUNG MCCOE32G", 4096},
{"ATA SAMSUNG MCCOE64G", 4096},
{"ATA SAMSUNG SSD PM80", 4096},
- /* Imported from Open Solaris*/
+ /* Imported from Open Solaris */
{"ATA MARVELL SD88SA02", 4096},
/* Advanced format Hard drives */
{"ATA Hitachi HDS5C303", 4096},
int i;
/* Prepare INQUIRY command */
- memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
+ memset(&io_hdr, 0, sizeof (sg_io_hdr_t));
io_hdr.interface_id = 'S';
- io_hdr.cmd_len = sizeof(inq_cmd_blk);
- io_hdr.mx_sb_len = sizeof(sense_buffer);
+ io_hdr.cmd_len = sizeof (inq_cmd_blk);
+ io_hdr.mx_sb_len = sizeof (sense_buffer);
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = INQ_REPLY_LEN;
io_hdr.dxferp = inq_buff;
io_hdr.cmdp = inq_cmd_blk;
io_hdr.sbp = sense_buffer;
- io_hdr.timeout = 10; /* 10 milliseconds is ample time */
+ io_hdr.timeout = 10; /* 10 milliseconds is ample time */
if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0)
return (B_FALSE);
} else {
err = -1;
vdev_error(gettext("%s contains a filesystem of "
- "type '%s'\n"), path, value);
+ "type '%s'\n"), path, value);
}
}
*/
static int
check_disk(const char *path, blkid_cache cache, int force,
- boolean_t isspare, boolean_t iswholedisk)
+ boolean_t isspare, boolean_t iswholedisk)
{
struct dk_gpt *vtoc;
char slice_path[MAXPATHLEN];
/* This is not a wholedisk we only check the given partition */
if (!iswholedisk)
- return check_slice(path, cache, force, isspare);
+ return (check_slice(path, cache, force, isspare));
/*
* When the device is a whole disk try to read the efi partition
*/
if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) {
check_error(errno);
- return -1;
+ return (-1);
}
if ((err = efi_alloc_and_read(fd, &vtoc)) != 0) {
(void) close(fd);
if (force) {
- return 0;
+ return (0);
} else {
vdev_error(gettext("%s does not contain an EFI "
"label but it may contain partition\n"
"information in the MBR.\n"), path);
- return -1;
+ return (-1);
}
}
if (force) {
/* Partitions will no be created using the backup */
- return 0;
+ return (0);
} else {
vdev_error(gettext("%s contains a corrupt primary "
"EFI label.\n"), path);
- return -1;
+ return (-1);
}
}
static int
check_device(const char *path, boolean_t force,
- boolean_t isspare, boolean_t iswholedisk)
+ boolean_t isspare, boolean_t iswholedisk)
{
static blkid_cache cache = NULL;
if ((err = blkid_get_cache(&cache, NULL)) != 0) {
check_error(err);
- return -1;
+ return (-1);
}
if ((err = blkid_probe_all(cache)) != 0) {
blkid_put_cache(cache);
check_error(err);
- return -1;
+ return (-1);
}
}
#endif /* HAVE_LIBBLKID */
- return check_disk(path, cache, force, isspare, iswholedisk);
+ return (check_disk(path, cache, force, isspare, iswholedisk));
}
/*
is_whole_disk(const char *path)
{
struct dk_gpt *label;
- int fd;
+ int fd;
if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0)
return (B_FALSE);
*/
static int
is_shorthand_path(const char *arg, char *path,
- struct stat64 *statbuf, boolean_t *wholedisk)
+ struct stat64 *statbuf, boolean_t *wholedisk)
{
int error;
return (0);
}
- strlcpy(path, arg, sizeof(path));
- memset(statbuf, 0, sizeof(*statbuf));
+ strlcpy(path, arg, sizeof (path));
+ memset(statbuf, 0, sizeof (*statbuf));
*wholedisk = B_FALSE;
return (error);
return (-1);
}
- return 0;
+ return (0);
}
/*
* and then block until udev creates the new link.
*/
if (!is_exclusive || !is_spare(NULL, udevpath)) {
- ret = strncmp(udevpath,UDISK_ROOT,strlen(UDISK_ROOT));
+ ret = strncmp(udevpath, UDISK_ROOT, strlen(UDISK_ROOT));
if (ret == 0) {
ret = lstat64(udevpath, &statbuf);
if (ret == 0 && S_ISLNK(statbuf.st_mode))
verify(!nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path));
if (strcmp(type, VDEV_TYPE_DISK) == 0)
verify(!nvlist_lookup_uint64(nv,
- ZPOOL_CONFIG_WHOLE_DISK, &wholedisk));
+ ZPOOL_CONFIG_WHOLE_DISK, &wholedisk));
/*
* As a generic check, we look to see if this is a replace of a
children * sizeof (nvlist_t *));
if (child == NULL)
zpool_no_memory();
- if ((nv = make_leaf_vdev(props, argv[c], B_FALSE))
- == NULL)
+ if ((nv = make_leaf_vdev(props, argv[c],
+ B_FALSE)) == NULL)
return (NULL);
child[children - 1] = nv;
}
* We have a device. Pass off to make_leaf_vdev() to
* construct the appropriate nvlist describing the vdev.
*/
- if ((nv = make_leaf_vdev(props, argv[0], is_log)) == NULL)
+ if ((nv = make_leaf_vdev(props, argv[0],
+ is_log)) == NULL)
return (NULL);
if (is_log)
nlogs++;
}
#undef OD_ARRAY_SIZE
-#define OD_ARRAY_SIZE 4
+#define OD_ARRAY_SIZE 4
/*
* Verify that dmu_object_{alloc,free} work as expected.
int size;
int b;
- size = sizeof(ztest_od_t) * OD_ARRAY_SIZE;
+ size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL);
batchsize = OD_ARRAY_SIZE;
}
#undef OD_ARRAY_SIZE
-#define OD_ARRAY_SIZE 2
+#define OD_ARRAY_SIZE 2
/*
* Verify that dmu_{read,write} work as expected.
ztest_od_t *od;
objset_t *os = zd->zd_os;
- size = sizeof(ztest_od_t) * OD_ARRAY_SIZE;
+ size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL);
dmu_tx_t *tx;
int i, freeit, error;
}
#undef OD_ARRAY_SIZE
-#define OD_ARRAY_SIZE 2
+#define OD_ARRAY_SIZE 2
void
ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
arc_buf_t **bigbuf_arcbufs;
dmu_object_info_t doi;
- size = sizeof(ztest_od_t) * OD_ARRAY_SIZE;
+ size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL);
/*
{
ztest_od_t *od;
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
uint64_t offset = (1ULL << (ztest_random(20) + 43)) +
(ztest_random(ZTEST_RANGE_LOCKS) << SPA_MAXBLOCKSHIFT);
while (ztest_random(10) != 0)
ztest_io(zd, od->od_object, offset);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
void
uint64_t blocksize = ztest_random_blocksize();
void *data;
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0);
- if (ztest_object_init(zd, od, sizeof (ztest_od_t), !ztest_random(2)) != 0) {
- umem_free(od, sizeof(ztest_od_t));
+ if (ztest_object_init(zd, od, sizeof (ztest_od_t),
+ !ztest_random(2)) != 0) {
+ umem_free(od, sizeof (ztest_od_t));
return;
}
if (ztest_truncate(zd, od->od_object, offset, count * blocksize) != 0) {
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
}
umem_free(data, blocksize);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
/*
int error;
char *hc[2] = { "s.acl.h", ".s.open.h.hyLZlg" };
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t),
VERIFY3U(0, ==, zap_remove(os, object, propname, tx));
dmu_tx_commit(tx);
out:
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
/*
uint64_t object, txg;
int i;
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t),
dmu_tx_commit(tx);
}
out:
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
/* ARGSUSED */
char name[20], string_value[20];
void *data;
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, ID_PARALLEL, FTAG, micro, DMU_OT_ZAP_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) {
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
if (tx != NULL)
dmu_tx_commit(tx);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
/*
uint64_t old_txg, txg;
int i, error = 0;
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) {
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
umem_free(cb_data[i], sizeof (ztest_cb_data_t));
}
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
dmu_tx_commit(tx);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
/* ARGSUSED */
dmu_objset_name(os, osname);
- (void) snprintf(snapname, sizeof (snapname), "sh1_%llu", (long long unsigned int)id);
+ (void) snprintf(snapname, sizeof (snapname), "sh1_%llu",
+ (u_longlong_t)id);
(void) snprintf(fullname, sizeof (fullname), "%s@%s", osname, snapname);
(void) snprintf(clonename, sizeof (clonename),
- "%s/ch1_%llu", osname, (long long unsigned int)id);
- (void) snprintf(tag, sizeof (tag), "tag_%llu", (long long unsigned int)id);
+ "%s/ch1_%llu", osname, (u_longlong_t)id);
+ (void) snprintf(tag, sizeof (tag), "tag_%llu", (u_longlong_t)id);
/*
* Clean up from any previous run.
blocksize = ztest_random_blocksize();
blocksize = MIN(blocksize, 2048); /* because we write so many */
- od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL);
+ od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) {
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_COPIES, 1,
B_FALSE) != 0) {
(void) rw_exit(&ztest_name_lock);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
txg = ztest_tx_assign(tx, TXG_WAIT, FTAG);
if (txg == 0) {
(void) rw_exit(&ztest_name_lock);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
return;
}
zio_buf_free(buf, psize);
(void) rw_exit(&ztest_name_lock);
- umem_free(od, sizeof(ztest_od_t));
+ umem_free(od, sizeof (ztest_od_t));
}
/*
return (NULL);
}
-#define GRACE 300
+#define GRACE 300
#if 0
static void
#include <sys/zfs_znode.h>
#include <sys/fs/zfs.h>
-int ioctl_get_msg(char *var, int fd)
+static int
+ioctl_get_msg(char *var, int fd)
{
int error = 0;
char msg[ZFS_MAXNAMELEN];
return (error);
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
int fd, error = 0;
char zvol_name[ZFS_MAXNAMELEN], zvol_name_part[ZFS_MAXNAMELEN];
*/
#ifndef _ZFS_BLKDEV_H
-#define _ZFS_BLKDEV_H
+#define _ZFS_BLKDEV_H
#include <linux/blkdev.h>
#include <linux/elevator.h>
if (req)
blkdev_dequeue_request(req);
- return req;
+ return (req);
}
#endif /* HAVE_BLK_FETCH_REQUEST */
req->hard_cur_sectors = nr_bytes >> 9;
end_request(req, ((error == 0) ? 1 : error));
- return 0;
+ return (0);
}
static inline bool
rc = __blk_end_request(req, error, nr_bytes);
spin_unlock_irq(q->queue_lock);
- return rc;
+ return (rc);
}
#else
-# ifdef HAVE_BLK_END_REQUEST_GPL_ONLY
+#ifdef HAVE_BLK_END_REQUEST_GPL_ONLY
/*
* Define required to avoid conflicting 2.6.29 non-static prototype for a
* GPL-only version of the helper. As of 2.6.31 the helper is available
* to non-GPL modules and is not explicitly exported GPL-only.
*/
-# define __blk_end_request __blk_end_request_x
-# define blk_end_request blk_end_request_x
+#define __blk_end_request __blk_end_request_x
+#define blk_end_request blk_end_request_x
static inline bool
__blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
req->hard_cur_sectors = nr_bytes >> 9;
end_request(req, ((error == 0) ? 1 : error));
- return 0;
+ return (0);
}
static inline bool
blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
rc = __blk_end_request_x(req, error, nr_bytes);
spin_unlock_irq(q->queue_lock);
- return rc;
+ return (rc);
}
-# endif /* HAVE_BLK_END_REQUEST_GPL_ONLY */
+#endif /* HAVE_BLK_END_REQUEST_GPL_ONLY */
#endif /* HAVE_BLK_END_REQUEST */
/*
* that long term this function will be opened up.
*/
#if defined(HAVE_BLK_QUEUE_FLUSH) && defined(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY)
-#define blk_queue_flush __blk_queue_flush
+#define blk_queue_flush __blk_queue_flush
static inline void
__blk_queue_flush(struct request_queue *q, unsigned int flags)
{
static inline sector_t
blk_rq_pos(struct request *req)
{
- return req->sector;
+ return (req->sector);
}
#endif /* HAVE_BLK_RQ_POS */
static inline unsigned int
blk_rq_sectors(struct request *req)
{
- return req->nr_sectors;
+ return (req->nr_sectors);
}
#endif /* HAVE_BLK_RQ_SECTORS */
* GPL-only version of the helper. As of 2.6.31 the helper is available
* to non-GPL modules in the form of a static inline in the header.
*/
-#define blk_rq_bytes __blk_rq_bytes
+#define blk_rq_bytes __blk_rq_bytes
static inline unsigned int
__blk_rq_bytes(struct request *req)
{
- return blk_rq_sectors(req) << 9;
+ return (blk_rq_sectors(req) << 9);
}
#endif /* !HAVE_BLK_RQ_BYTES || HAVE_BLK_RQ_BYTES_GPL_ONLY */
* macros are redefined here if they are missing from the kernel.
*/
#ifndef blk_fs_request
-#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS)
+#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS)
#endif
/*
* this legacy behavior.
*/
#ifndef blk_queue_stackable
-#define blk_queue_stackable(q) ((q)->request_fn == NULL)
+#define blk_queue_stackable(q) ((q)->request_fn == NULL)
#endif
/*
* The blk_queue_max_hw_sectors() function replaces blk_queue_max_sectors().
*/
#ifndef HAVE_BLK_QUEUE_MAX_HW_SECTORS
-#define blk_queue_max_hw_sectors __blk_queue_max_hw_sectors
+#define blk_queue_max_hw_sectors __blk_queue_max_hw_sectors
static inline void
__blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
{
* blk_queue_max_hw_segments() and blk_queue_max_phys_segments().
*/
#ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
-#define blk_queue_max_segments __blk_queue_max_segments
+#define blk_queue_max_segments __blk_queue_max_segments
static inline void
__blk_queue_max_segments(struct request_queue *q, unsigned short max_segments)
{
* a read-modify-write penalty. For older kernels this is a no-op.
*/
#ifndef HAVE_BLK_QUEUE_PHYSICAL_BLOCK_SIZE
-#define blk_queue_physical_block_size(q, x) ((void)(0))
+#define blk_queue_physical_block_size(q, x) ((void)(0))
#endif
/*
* I/O size for the device. For older kernels this is a no-op.
*/
#ifndef HAVE_BLK_QUEUE_IO_OPT
-#define blk_queue_io_opt(q, x) ((void)(0))
+#define blk_queue_io_opt(q, x) ((void)(0))
#endif
#ifndef HAVE_GET_DISK_RO
if (disk->part[0])
policy = disk->part[0]->policy;
- return policy;
+ return (policy);
}
#endif /* HAVE_GET_DISK_RO */
struct bio *bio;
};
-# define for_each_bio(_bio) \
+#define for_each_bio(_bio) \
for (; _bio; _bio = _bio->bi_next)
-# define __rq_for_each_bio(_bio, rq) \
+#define __rq_for_each_bio(_bio, rq) \
if ((rq->bio)) \
for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
-# define rq_for_each_segment(bvl, _rq, _iter) \
+#define rq_for_each_segment(bvl, _rq, _iter) \
__rq_for_each_bio(_iter.bio, _rq) \
bio_for_each_segment(bvl, _iter.bio, _iter.i)
#endif /* HAVE_RQ_FOR_EACH_SEGMENT */
#ifdef HAVE_BIO_RW_FAILFAST_DTD
/* BIO_RW_FAILFAST_* preferred interface from 2.6.28 - 2.6.35 */
- *flags |=
- ((1 << BIO_RW_FAILFAST_DEV) |
- (1 << BIO_RW_FAILFAST_TRANSPORT) |
- (1 << BIO_RW_FAILFAST_DRIVER));
+ *flags |= (
+ (1 << BIO_RW_FAILFAST_DEV) |
+ (1 << BIO_RW_FAILFAST_TRANSPORT) |
+ (1 << BIO_RW_FAILFAST_DRIVER));
#else
-# ifdef HAVE_BIO_RW_FAILFAST
+#ifdef HAVE_BIO_RW_FAILFAST
/* BIO_RW_FAILFAST preferred interface from 2.6.12 - 2.6.27 */
*flags |= (1 << BIO_RW_FAILFAST);
-# else
-# ifdef HAVE_REQ_FAILFAST_MASK
- /* REQ_FAILFAST_* preferred interface from 2.6.36 - 2.6.xx,
- * the BIO_* and REQ_* flags were unified under REQ_* flags. */
+#else
+#ifdef HAVE_REQ_FAILFAST_MASK
+ /*
+ * REQ_FAILFAST_* preferred interface from 2.6.36 - 2.6.xx,
+ * the BIO_* and REQ_* flags were unified under REQ_* flags.
+ */
*flags |= REQ_FAILFAST_MASK;
-# endif /* HAVE_REQ_FAILFAST_MASK */
-# endif /* HAVE_BIO_RW_FAILFAST */
+#endif /* HAVE_REQ_FAILFAST_MASK */
+#endif /* HAVE_BIO_RW_FAILFAST */
#endif /* HAVE_BIO_RW_FAILFAST_DTD */
}
* Maximum disk label length, it may be undefined for some kernels.
*/
#ifndef DISK_NAME_LEN
-#define DISK_NAME_LEN 32
+#define DISK_NAME_LEN 32
#endif /* DISK_NAME_LEN */
/*
* macro's to ensure the prototype and return value are handled.
*/
#ifdef HAVE_2ARGS_BIO_END_IO_T
-# define BIO_END_IO_PROTO(fn, x, y, z) static void fn(struct bio *x, int z)
-# define BIO_END_IO_RETURN(rc) return
+#define BIO_END_IO_PROTO(fn, x, y, z) static void fn(struct bio *x, int z)
+#define BIO_END_IO_RETURN(rc) return
#else
-# define BIO_END_IO_PROTO(fn, x, y, z) static int fn(struct bio *x, \
- unsigned int y, int z)
-# define BIO_END_IO_RETURN(rc) return rc
+#define BIO_END_IO_PROTO(fn, x, y, z) static int fn( \
+ struct bio *x, \
+ unsigned int y, \
+ int z)
+#define BIO_END_IO_RETURN(rc) return rc
#endif /* HAVE_2ARGS_BIO_END_IO_T */
/*
* Used to exclusively open a block device from within the kernel.
*/
#if defined(HAVE_BLKDEV_GET_BY_PATH)
-# define vdev_bdev_open(path, md, hld) blkdev_get_by_path(path, \
+#define vdev_bdev_open(path, md, hld) blkdev_get_by_path(path, \
(md) | FMODE_EXCL, hld)
-# define vdev_bdev_close(bdev, md) blkdev_put(bdev, (md) | FMODE_EXCL)
+#define vdev_bdev_close(bdev, md) blkdev_put(bdev, (md) | FMODE_EXCL)
#elif defined(HAVE_OPEN_BDEV_EXCLUSIVE)
-# define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld)
-# define vdev_bdev_close(bdev, md) close_bdev_exclusive(bdev, md)
+#define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld)
+#define vdev_bdev_close(bdev, md) close_bdev_exclusive(bdev, md)
#else
-# define vdev_bdev_open(path, md, hld) open_bdev_excl(path, md, hld)
-# define vdev_bdev_close(bdev, md) close_bdev_excl(bdev)
+#define vdev_bdev_open(path, md, hld) open_bdev_excl(path, md, hld)
+#define vdev_bdev_close(bdev, md) close_bdev_excl(bdev)
#endif /* HAVE_BLKDEV_GET_BY_PATH | HAVE_OPEN_BDEV_EXCLUSIVE */
/*
* it was unused.
*/
#ifdef HAVE_1ARG_INVALIDATE_BDEV
-# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev)
+#define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev)
#else
-# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev, 1)
+#define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev, 1)
#endif /* HAVE_1ARG_INVALIDATE_BDEV */
/*
* symbol was not exported.
*/
#ifndef HAVE_LOOKUP_BDEV
-# define lookup_bdev(path) ERR_PTR(-ENOTSUP)
+#define lookup_bdev(path) ERR_PTR(-ENOTSUP)
#endif
/*
* the logical block size interface and then the older hard sector size.
*/
#ifdef HAVE_BDEV_PHYSICAL_BLOCK_SIZE
-# define vdev_bdev_block_size(bdev) bdev_physical_block_size(bdev)
+#define vdev_bdev_block_size(bdev) bdev_physical_block_size(bdev)
+#else
+#ifdef HAVE_BDEV_LOGICAL_BLOCK_SIZE
+#define vdev_bdev_block_size(bdev) bdev_logical_block_size(bdev)
#else
-# ifdef HAVE_BDEV_LOGICAL_BLOCK_SIZE
-# define vdev_bdev_block_size(bdev) bdev_logical_block_size(bdev)
-# else
-# define vdev_bdev_block_size(bdev) bdev_hardsect_size(bdev)
-# endif /* HAVE_BDEV_LOGICAL_BLOCK_SIZE */
+#define vdev_bdev_block_size(bdev) bdev_hardsect_size(bdev)
+#endif /* HAVE_BDEV_LOGICAL_BLOCK_SIZE */
#endif /* HAVE_BDEV_PHYSICAL_BLOCK_SIZE */
/*
* compatibility macros.
*/
#ifdef WRITE_FLUSH_FUA
-# define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
-# define VDEV_REQ_FLUSH REQ_FLUSH
-# define VDEV_REQ_FUA REQ_FUA
+#define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
+#define VDEV_REQ_FLUSH REQ_FLUSH
+#define VDEV_REQ_FUA REQ_FUA
#else
-# define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER
-# define VDEV_REQ_FLUSH REQ_HARDBARRIER
-# define VDEV_REQ_FUA REQ_HARDBARRIER
+#define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER
+#define VDEV_REQ_FLUSH REQ_HARDBARRIER
+#define VDEV_REQ_FUA REQ_HARDBARRIER
#endif
/*
* Use the normal I/O patch for discards.
*/
#ifdef REQ_DISCARD
-# define VDEV_REQ_DISCARD REQ_DISCARD
+#define VDEV_REQ_DISCARD REQ_DISCARD
#endif
/*
q->limits.discard_granularity = dg;
}
#else
-#define blk_queue_discard_granularity(x, dg) ((void)0)
+#define blk_queue_discard_granularity(x, dg) ((void)0)
#endif /* HAVE_DISCARD_GRANULARITY */
/*
* user space processes which don't pass this value will get EBUSY. This is
* currently required for the correct operation of hot spares.
*/
-#define VDEV_HOLDER ((void *)0x2401de7)
+#define VDEV_HOLDER ((void *)0x2401de7)
#endif /* _ZFS_BLKDEV_H */
*/
#ifndef _ZFS_DCACHE_H
-#define _ZFS_DCACHE_H
+#define _ZFS_DCACHE_H
#include <linux/dcache.h>
-#define dname(dentry) ((char *)((dentry)->d_name.name))
-#define dlen(dentry) ((int)((dentry)->d_name.len))
+#define dname(dentry) ((char *)((dentry)->d_name.name))
+#define dlen(dentry) ((int)((dentry)->d_name.len))
#ifndef HAVE_D_MAKE_ROOT
-#define d_make_root(inode) d_alloc_root(inode)
+#define d_make_root(inode) d_alloc_root(inode)
#endif /* HAVE_D_MAKE_ROOT */
/*
{
#ifdef HAVE_D_SET_D_OP
dentry->d_op = NULL;
- dentry->d_flags &=
- ~(DCACHE_OP_HASH | DCACHE_OP_COMPARE |
- DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE);
+ dentry->d_flags &= ~(
+ DCACHE_OP_HASH | DCACHE_OP_COMPARE |
+ DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE);
#endif /* HAVE_D_SET_D_OP */
}
*/
#ifndef _ZFS_VFS_H
-#define _ZFS_VFS_H
+#define _ZFS_VFS_H
/*
* 2.6.28 API change,
extern atomic_long_t zfs_bdi_seq;
static inline int
-bdi_setup_and_register(struct backing_dev_info *bdi,char *name,unsigned int cap)
+bdi_setup_and_register(
+ struct backing_dev_info *bdi,
+ char *name,
+ unsigned int cap)
{
char tmp[32];
int error;
* LOOKUP_RCU flag introduced to distinguish rcu-walk from ref-walk cases.
*/
#ifndef LOOKUP_RCU
-#define LOOKUP_RCU 0x0
+#define LOOKUP_RCU 0x0
#endif /* LOOKUP_RCU */
/*
* configure check in config/kernel-clear-inode.m4 for full details.
*/
#if defined(HAVE_EVICT_INODE) && !defined(HAVE_CLEAR_INODE)
-#define clear_inode(ip) end_writeback(ip)
+#define clear_inode(ip) end_writeback(ip)
#endif /* HAVE_EVICT_INODE && !HAVE_CLEAR_INODE */
/*
* The sget() helper function now takes the mount flags as an argument.
*/
#ifdef HAVE_5ARG_SGET
-#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, fl, mtd)
+#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, fl, mtd)
#else
-#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, mtd)
+#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, mtd)
#endif /* HAVE_5ARG_SGET */
-#define ZFS_IOC_GETFLAGS FS_IOC_GETFLAGS
-#define ZFS_IOC_SETFLAGS FS_IOC_SETFLAGS
+#define ZFS_IOC_GETFLAGS FS_IOC_GETFLAGS
+#define ZFS_IOC_SETFLAGS FS_IOC_SETFLAGS
#if defined(SEEK_HOLE) && defined(SEEK_DATA) && !defined(HAVE_LSEEK_EXECUTE)
static inline loff_t
-lseek_execute(struct file *filp, struct inode *inode,
- loff_t offset, loff_t maxsize)
+lseek_execute(
+ struct file *filp,
+ struct inode *inode,
+ loff_t offset,
+ loff_t maxsize)
{
if (offset < 0 && !(filp->f_mode & FMODE_UNSIGNED_OFFSET))
return (-EINVAL);
*/
#include <linux/posix_acl.h>
#ifndef HAVE_POSIX_ACL_CACHING
-#define ACL_NOT_CACHED ((void *)(-1))
+#define ACL_NOT_CACHED ((void *)(-1))
#endif /* HAVE_POSIX_ACL_CACHING */
#if defined(HAVE_POSIX_ACL_RELEASE) && !defined(HAVE_POSIX_ACL_RELEASE_GPL_ONLY)
if ((newer != ACL_NOT_CACHED) && (newer != NULL))
posix_acl_dup(newer);
- switch(type) {
+ switch (type) {
case ACL_TYPE_ACCESS:
older = ip->i_acl;
- rcu_assign_pointer(ip->i_acl,newer);
+ rcu_assign_pointer(ip->i_acl, newer);
break;
case ACL_TYPE_DEFAULT:
older = ip->i_default_acl;
- rcu_assign_pointer(ip->i_default_acl,newer);
+ rcu_assign_pointer(ip->i_default_acl, newer);
break;
}
*acl = NULL;
}
- return (error);
+ return (error);
}
static inline int
-posix_acl_create(struct posix_acl** acl, int flags, umode_t* umodep) {
+posix_acl_create(struct posix_acl **acl, int flags, umode_t *umodep) {
struct posix_acl *oldacl = *acl;
mode_t mode = *umodep;
int error;
*/
#ifndef _ZFS_XATTR_H
-#define _ZFS_XATTR_H
+#define _ZFS_XATTR_H
#include <linux/posix_acl_xattr.h>
* instead of an inode, and a handler_flags argument was added.
*/
#ifdef HAVE_DENTRY_XATTR_GET
-#define ZPL_XATTR_GET_WRAPPER(fn) \
+#define ZPL_XATTR_GET_WRAPPER(fn) \
static int \
fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
int unused_handler_flags) \
{ \
- return __ ## fn(dentry->d_inode, name, buffer, size); \
+ return (__ ## fn(dentry->d_inode, name, buffer, size)); \
}
#else
-#define ZPL_XATTR_GET_WRAPPER(fn) \
+#define ZPL_XATTR_GET_WRAPPER(fn) \
static int \
fn(struct inode *ip, const char *name, void *buffer, size_t size) \
{ \
- return __ ## fn(ip, name, buffer, size); \
+ return (__ ## fn(ip, name, buffer, size)); \
}
#endif /* HAVE_DENTRY_XATTR_GET */
* instead of an inode, and a handler_flags argument was added.
*/
#ifdef HAVE_DENTRY_XATTR_SET
-#define ZPL_XATTR_SET_WRAPPER(fn) \
+#define ZPL_XATTR_SET_WRAPPER(fn) \
static int \
fn(struct dentry *dentry, const char *name, const void *buffer, \
size_t size, int flags, int unused_handler_flags) \
{ \
- return __ ## fn(dentry->d_inode, name, buffer, size, flags); \
+ return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
}
#else
-#define ZPL_XATTR_SET_WRAPPER(fn) \
+#define ZPL_XATTR_SET_WRAPPER(fn) \
static int \
fn(struct inode *ip, const char *name, const void *buffer, \
size_t size, int flags) \
{ \
- return __ ## fn(ip, name, buffer, size, flags); \
+ return (__ ## fn(ip, name, buffer, size, flags)); \
}
#endif /* HAVE_DENTRY_XATTR_SET */
#ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
-#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
+#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_inode_init_security(ip, dip, qstr, nm, val, len)
#else
-#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
+#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_inode_init_security(ip, dip, nm, val, len)
#endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
static inline struct posix_acl *
zpl_acl_from_xattr(const void *value, int size)
{
- return posix_acl_from_xattr(CRED()->user_ns, value, size);
+ return (posix_acl_from_xattr(CRED()->user_ns, value, size));
}
static inline int
zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
{
- return posix_acl_to_xattr(CRED()->user_ns,acl, value, size);
+ return (posix_acl_to_xattr(CRED()->user_ns, acl, value, size));
}
#else
static inline struct posix_acl *
-zpl_acl_from_xattr(const void *value,int size)
+zpl_acl_from_xattr(const void *value, int size)
{
- return posix_acl_from_xattr(value, size);
+ return (posix_acl_from_xattr(value, size));
}
static inline int
zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
{
- return posix_acl_to_xattr(acl, value, size);
+ return (posix_acl_to_xattr(acl, value, size));
}
#endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */
extern dmu_tx_stats_t dmu_tx_stats;
-#define DMU_TX_STAT_INCR(stat, val) \
+#define DMU_TX_STAT_INCR(stat, val) \
atomic_add_64(&dmu_tx_stats.stat.value.ui64, (val));
-#define DMU_TX_STAT_BUMP(stat) \
+#define DMU_TX_STAT_BUMP(stat) \
DMU_TX_STAT_INCR(stat, 1);
/*
#define FM_EREPORT_ZFS_CONFIG_SYNC "config.sync"
#define FM_EREPORT_ZFS_POOL "zpool"
#define FM_EREPORT_ZFS_POOL_DESTROY "zpool.destroy"
-#define FM_EREPORT_ZFS_POOL_REGUID "zpool.reguid"
+#define FM_EREPORT_ZFS_POOL_REGUID "zpool.reguid"
#define FM_EREPORT_ZFS_DEVICE_UNKNOWN "vdev.unknown"
#define FM_EREPORT_ZFS_DEVICE_OPEN_FAILED "vdev.open_failed"
#define FM_EREPORT_ZFS_DEVICE_CORRUPT_DATA "vdev.corrupt_data"
#ifdef _KERNEL
-#define ZEVENT_SHUTDOWN 0x1
+#define ZEVENT_SHUTDOWN 0x1
typedef void zevent_cb_t(nvlist_t *, nvlist_t *);
typedef struct zevent_s {
- nvlist_t *ev_nvl; /* protected by the zevent_lock */
- nvlist_t *ev_detector; /* " */
- list_t ev_ze_list; /* " */
- list_node_t ev_node; /* " */
- zevent_cb_t *ev_cb; /* " */
+ nvlist_t *ev_nvl; /* protected by the zevent_lock */
+ nvlist_t *ev_detector; /* " */
+ list_t ev_ze_list; /* " */
+ list_node_t ev_node; /* " */
+ zevent_cb_t *ev_cb; /* " */
} zevent_t;
typedef struct zfs_zevent {
- zevent_t *ze_zevent; /* protected by the zevent_lock */
- list_node_t ze_node; /* " */
- uint64_t ze_dropped; /* " */
+ zevent_t *ze_zevent; /* protected by the zevent_lock */
+ list_node_t ze_node; /* " */
+ uint64_t ze_dropped; /* " */
} zfs_zevent_t;
extern void fm_init(void);
/*
* zvol ioctl to get dataset name
*/
-#define BLKZNAME _IOR(0x12,125,char[ZFS_MAXNAMELEN])
+#define BLKZNAME _IOR(0x12, 125, char[ZFS_MAXNAMELEN])
/*
* Internal SPA load state. Used by FMA diagnosis engine.
*/
#ifndef _SYS_VDEV_DISK_H
-#define _SYS_VDEV_DISK_H
+#define _SYS_VDEV_DISK_H
#ifdef _KERNEL
#include <sys/vdev.h>
typedef void (*thread_func_arg_t)(void *);
typedef pthread_t kt_did_t;
-#define kpreempt(x) ((void)0)
+#define kpreempt(x) ((void)0)
typedef struct kthread {
kt_did_t t_tid;
#define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \
sysevent_post_event(_c, _d, _b, "libzpool", _e, _f)
-#define zfs_sleep_until(wakeup) \
+#define zfs_sleep_until(wakeup) \
do { \
hrtime_t delta = wakeup - gethrtime(); \
struct timespec ts; \
* filtered based on the zfs_flags variable.
*/
#else
-#define dprintf(...) \
+#define dprintf(...) \
if (zfs_flags & ZFS_DEBUG_DPRINTF) \
__dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
extern void zfs_dbgmsg_init(void);
extern void zfs_dbgmsg_fini(void);
#if defined(_KERNEL) && defined(__linux__)
-#define zfs_dbgmsg(...) dprintf(__VA_ARGS__)
+#define zfs_dbgmsg(...) dprintf(__VA_ARGS__)
#else
extern void zfs_dbgmsg(const char *fmt, ...);
extern void zfs_dbgmsg_print(const char *tag);
/*
* Generic wrapper to sleep until a given time.
*/
-#define zfs_sleep_until(wakeup) \
+#define zfs_sleep_until(wakeup) \
do { \
hrtime_t delta = wakeup - gethrtime(); \
\
};
typedef struct zfsdev_state {
- list_node_t zs_next; /* next zfsdev_state_t link */
+ list_node_t zs_next; /* next zfsdev_state_t link */
struct file *zs_file; /* associated file struct */
minor_t zs_minor; /* made up minor number */
void *zs_onexit; /* onexit data */
#ifdef _KERNEL
-#define DXATTR_MAX_ENTRY_SIZE (32768)
-#define DXATTR_MAX_SA_SIZE (SPA_MAXBLOCKSIZE >> 1)
+#define DXATTR_MAX_ENTRY_SIZE (32768)
+#define DXATTR_MAX_SA_SIZE (SPA_MAXBLOCKSIZE >> 1)
int zfs_sa_readlink(struct znode *, uio_t *);
void zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *);
krwlock_t z_teardown_inactive_lock;
list_t z_all_znodes; /* all znodes in the fs */
uint64_t z_nr_znodes; /* number of znodes in the fs */
- unsigned long z_rollback_time;/* last online rollback time */
+ unsigned long z_rollback_time; /* last online rollback time */
kmutex_t z_znodes_lock; /* lock for z_all_znodes */
struct inode *z_ctldir; /* .zfs directory inode */
avl_tree_t z_ctldir_snaps; /* .zfs/snapshot entries */
* this the inode->i_nlink member is defined as an unsigned int. To be
* safe we use 2^31-1 as the limit.
*/
-#define ZFS_LINK_MAX ((1U << 31) - 1U)
+#define ZFS_LINK_MAX ((1U << 31) - 1U)
/*
* Normal filesystems (those not under .zfs/snapshot) have a total
kmutex_t z_acl_lock; /* acl data lock */
zfs_acl_t *z_acl_cached; /* cached acl */
krwlock_t z_xattr_lock; /* xattr data lock */
- nvlist_t *z_xattr_cached;/* cached xattrs */
- struct znode *z_xattr_parent;/* xattr parent znode */
+ nvlist_t *z_xattr_cached; /* cached xattrs */
+ struct znode *z_xattr_parent; /* xattr parent znode */
list_node_t z_link_node; /* all znodes in fs link */
sa_handle_t *z_sa_hdl; /* handle to sa data */
boolean_t z_is_sa; /* are we native sa? */
extern zil_stats_t zil_stats;
-#define ZIL_STAT_INCR(stat, val) \
+#define ZIL_STAT_INCR(stat, val) \
atomic_add_64(&zil_stats.stat.value.ui64, (val));
-#define ZIL_STAT_BUMP(stat) \
+#define ZIL_STAT_BUMP(stat) \
ZIL_STAT_INCR(stat, 1);
typedef int zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg,
typedef struct lwb {
zilog_t *lwb_zilog; /* back pointer to log struct */
blkptr_t lwb_blk; /* on disk address of this log blk */
- boolean_t lwb_fastwrite; /* is blk marked for fastwrite? */
+ boolean_t lwb_fastwrite; /* is blk marked for fastwrite? */
int lwb_nused; /* # used bytes in buffer */
int lwb_sz; /* size of block and buffer */
char *lwb_buf; /* log write buffer */
/*
* Default Linux timeout for a sd device.
*/
-#define ZIO_DELAY_MAX (30 * MILLISEC)
+#define ZIO_DELAY_MAX (30 * MILLISEC)
#define ZIO_FAILURE_MODE_WAIT 0
#define ZIO_FAILURE_MODE_CONTINUE 1
extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
#if !defined(HAVE_GET_ACL)
#if defined(HAVE_CHECK_ACL_WITH_FLAGS)
-extern int zpl_check_acl(struct inode *inode, int mask,unsigned int flags);
+extern int zpl_check_acl(struct inode *inode, int mask, unsigned int flags);
#elif defined(HAVE_CHECK_ACL)
extern int zpl_check_acl(struct inode *inode, int mask);
#elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
#ifdef HAVE_VFS_ITERATE
-#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
+#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
.actor = _actor, \
.pos = _pos, \
}
loff_t pos;
} dir_context_t;
-#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
+#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
.dirent = _dirent, \
.actor = _actor, \
.pos = _pos, \
dir_emit(struct dir_context *ctx, const char *name, int namelen,
uint64_t ino, unsigned type)
{
- return ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type) == 0;
+ return (ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type)
+ == 0);
}
static inline bool
dir_emit_dot(struct file *file, struct dir_context *ctx)
{
- return ctx->actor(ctx->dirent, ".", 1, ctx->pos,
- file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0;
+ return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
+ file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0);
}
static inline bool
dir_emit_dotdot(struct file *file, struct dir_context *ctx)
{
- return ctx->actor(ctx->dirent, "..", 2, ctx->pos,
- parent_ino(file->f_path.dentry), DT_DIR) == 0;
+ return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
+ parent_ino(file->f_path.dentry), DT_DIR) == 0);
}
static inline bool
{
if (ctx->pos == 0) {
if (!dir_emit_dot(file, ctx))
- return false;
+ return (false);
ctx->pos = 1;
}
if (ctx->pos == 1) {
if (!dir_emit_dotdot(file, ctx))
- return false;
+ return (false);
ctx->pos = 2;
}
- return true;
+ return (true);
}
#endif /* HAVE_VFS_ITERATE */
-/*****************************************************************************\
+/*
* ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space.
*
* You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
#ifndef _ZPIOS_CTL_H
-#define _ZPIOS_CTL_H
+#define _ZPIOS_CTL_H
-/* Contains shared definitions which both the userspace
+/*
+ * Contains shared definitions which both the userspace
* and kernelspace portions of zpios must agree on.
*/
#ifndef _KERNEL
#include <stdint.h>
#endif
-#define ZPIOS_MAJOR 232 /* XXX - Arbitrary */
-#define ZPIOS_MINORS 1
-#define ZPIOS_NAME "zpios"
-#define ZPIOS_DEV "/dev/zpios"
-
-#define DMU_IO 0x01
-
-#define DMU_WRITE 0x0001
-#define DMU_READ 0x0002
-#define DMU_VERIFY 0x0004
-#define DMU_REMOVE 0x0008
-#define DMU_FPP 0x0010
-#define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */
-#define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */
-#define DMU_WRITE_NOWAIT 0x0080
-#define DMU_READ_NOPF 0x0100
-
-#define ZPIOS_NAME_SIZE 16
-#define ZPIOS_PATH_SIZE 128
-
-#define PHASE_PRE_RUN "pre-run"
-#define PHASE_PRE_CREATE "pre-create"
-#define PHASE_PRE_WRITE "pre-write"
-#define PHASE_PRE_READ "pre-read"
-#define PHASE_PRE_REMOVE "pre-remove"
-#define PHASE_POST_RUN "post-run"
-#define PHASE_POST_CREATE "post-create"
-#define PHASE_POST_WRITE "post-write"
-#define PHASE_POST_READ "post-read"
-#define PHASE_POST_REMOVE "post-remove"
+#define ZPIOS_MAJOR 232 /* XXX - Arbitrary */
+#define ZPIOS_MINORS 1
+#define ZPIOS_NAME "zpios"
+#define ZPIOS_DEV "/dev/zpios"
+
+#define DMU_IO 0x01
+
+#define DMU_WRITE 0x0001
+#define DMU_READ 0x0002
+#define DMU_VERIFY 0x0004
+#define DMU_REMOVE 0x0008
+#define DMU_FPP 0x0010
+#define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */
+#define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */
+#define DMU_WRITE_NOWAIT 0x0080
+#define DMU_READ_NOPF 0x0100
+
+#define ZPIOS_NAME_SIZE 16
+#define ZPIOS_PATH_SIZE 128
+
+#define PHASE_PRE_RUN "pre-run"
+#define PHASE_PRE_CREATE "pre-create"
+#define PHASE_PRE_WRITE "pre-write"
+#define PHASE_PRE_READ "pre-read"
+#define PHASE_PRE_REMOVE "pre-remove"
+#define PHASE_POST_RUN "post-run"
+#define PHASE_POST_CREATE "post-create"
+#define PHASE_POST_WRITE "post-write"
+#define PHASE_POST_READ "post-read"
+#define PHASE_POST_REMOVE "post-remove"
#define ZPIOS_CFG_MAGIC 0x87237190U
typedef struct zpios_cfg {
uint32_t cmd_chunk_noise; /* Chunk noise */
uint32_t cmd_thread_delay; /* Thread delay */
uint32_t cmd_flags; /* Test flags */
- char cmd_pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
- char cmd_post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
+ char cmd_pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
+ char cmd_post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
char cmd_log[ZPIOS_PATH_SIZE]; /* Requested log dir */
uint64_t cmd_data_size; /* Opaque data size */
char cmd_data_str[0]; /* Opaque data region */
} zpios_cmd_t;
/* Valid ioctls */
-#define ZPIOS_CFG _IOWR('f', 101, zpios_cfg_t)
-#define ZPIOS_CMD _IOWR('f', 102, zpios_cmd_t)
+#define ZPIOS_CFG _IOWR('f', 101, zpios_cfg_t)
+#define ZPIOS_CMD _IOWR('f', 102, zpios_cmd_t)
/* Valid configuration commands */
-#define ZPIOS_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
-#define ZPIOS_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
+#define ZPIOS_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
+#define ZPIOS_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
#ifndef NSEC_PER_SEC
-#define NSEC_PER_SEC 1000000000L
+#define NSEC_PER_SEC 1000000000L
#endif
static inline
-void zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec)
+void
+zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec)
{
while (nsec >= NSEC_PER_SEC) {
nsec -= NSEC_PER_SEC;
}
static inline
-zpios_timespec_t zpios_timespec_add(zpios_timespec_t lhs, zpios_timespec_t rhs)
+zpios_timespec_t
+zpios_timespec_add(zpios_timespec_t lhs, zpios_timespec_t rhs)
{
zpios_timespec_t ts_delta;
zpios_timespec_normalize(&ts_delta, lhs.ts_sec + rhs.ts_sec,
- lhs.ts_nsec + rhs.ts_nsec);
- return ts_delta;
+ lhs.ts_nsec + rhs.ts_nsec);
+ return (ts_delta);
}
static inline
-zpios_timespec_t zpios_timespec_sub(zpios_timespec_t lhs, zpios_timespec_t rhs)
+zpios_timespec_t
+zpios_timespec_sub(zpios_timespec_t lhs, zpios_timespec_t rhs)
{
zpios_timespec_t ts_delta;
zpios_timespec_normalize(&ts_delta, lhs.ts_sec - rhs.ts_sec,
- lhs.ts_nsec - rhs.ts_nsec);
- return ts_delta;
+ lhs.ts_nsec - rhs.ts_nsec);
+ return (ts_delta);
}
#ifdef _KERNEL
static inline
-zpios_timespec_t zpios_timespec_now(void)
+zpios_timespec_t
+zpios_timespec_now(void)
{
zpios_timespec_t zts_now;
struct timespec ts_now;
zts_now.ts_sec = ts_now.tv_sec;
zts_now.ts_nsec = ts_now.tv_nsec;
- return zts_now;
+ return (zts_now);
}
#else
static inline
-double zpios_timespec_to_double(zpios_timespec_t ts)
+double
+zpios_timespec_to_double(zpios_timespec_t ts)
{
- return ((double)(ts.ts_sec) +
- ((double)(ts.ts_nsec) / (double)(NSEC_PER_SEC)));
+ return
+ ((double)(ts.ts_sec) +
+ ((double)(ts.ts_nsec) / (double)(NSEC_PER_SEC)));
}
#endif /* _KERNEL */
-/*****************************************************************************\
+/*
* ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space.
*
* You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
#ifndef _ZPIOS_INTERNAL_H
-#define _ZPIOS_INTERNAL_H
+#define _ZPIOS_INTERNAL_H
#include "zpios-ctl.h"
-#define OBJ_SIZE 64
+#define OBJ_SIZE 64
struct run_args;
int thread_no;
int rc;
zpios_stats_t stats;
- kmutex_t lock;
+ kmutex_t lock;
} thread_data_t;
/* region for IO data */
__u64 max_offset;
dmu_obj_t obj;
zpios_stats_t stats;
- kmutex_t lock;
+ kmutex_t lock;
} zpios_region_t;
/* arguments for one run */
/* Control data */
objset_t *os;
- wait_queue_head_t waitq;
+ wait_queue_head_t waitq;
volatile uint64_t threads_done;
- kmutex_t lock_work;
+ kmutex_t lock_work;
kmutex_t lock_ctl;
__u32 region_next;
zpios_region_t regions[0]; /* Must be last element */
} run_args_t;
-#define ZPIOS_INFO_BUFFER_SIZE 65536
-#define ZPIOS_INFO_BUFFER_REDZONE 1024
+#define ZPIOS_INFO_BUFFER_SIZE 65536
+#define ZPIOS_INFO_BUFFER_REDZONE 1024
typedef struct zpios_info {
- spinlock_t info_lock;
- int info_size;
- char *info_buffer;
- char *info_head; /* Internal kernel use only */
+ spinlock_t info_lock;
+ int info_size;
+ char *info_buffer;
+ char *info_head; /* Internal kernel use only */
} zpios_info_t;
-#define zpios_print(file, format, args...) \
-({ zpios_info_t *_info_ = (zpios_info_t *)file->private_data; \
- int _rc_; \
- \
- ASSERT(_info_); \
- ASSERT(_info_->info_buffer); \
- \
- spin_lock(&_info_->info_lock); \
- \
- /* Don't allow the kernel to start a write in the red zone */ \
- if ((int)(_info_->info_head - _info_->info_buffer) > \
- (_info_->info_size - ZPIOS_INFO_BUFFER_REDZONE)) { \
- _rc_ = -EOVERFLOW; \
- } else { \
- _rc_ = sprintf(_info_->info_head, format, args); \
- if (_rc_ >= 0) \
- _info_->info_head += _rc_; \
- } \
- \
- spin_unlock(&_info_->info_lock); \
- _rc_; \
-})
-
-#define zpios_vprint(file, test, format, args...) \
- zpios_print(file, "%*s: " format, ZPIOS_NAME_SIZE, test, args)
-
#endif /* _ZPIOS_INTERNAL_H */
int sector_size;
unsigned long long capacity_size;
- if (ioctl(fd, BLKSSZGET, §or_size) < 0)
- return (-1);
+ if (ioctl(fd, BLKSSZGET, §or_size) < 0)
+ return (-1);
if (ioctl(fd, BLKGETSIZE64, &capacity_size) < 0)
return (-1);
char *dev_path;
int rval = 0;
- memset(dki_info, 0, sizeof(*dki_info));
+ memset(dki_info, 0, sizeof (*dki_info));
path = calloc(PATH_MAX, 1);
if (path == NULL)
strcpy(dki_info->dki_cname, "sd");
dki_info->dki_ctype = DKC_SCSI_CCS;
rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/hd", 7) == 0)) {
strcpy(dki_info->dki_cname, "hd");
dki_info->dki_ctype = DKC_DIRECT;
rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/md", 7) == 0)) {
strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_MD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/vd", 7) == 0)) {
strcpy(dki_info->dki_cname, "vd");
dki_info->dki_ctype = DKC_MD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/dm-", 8) == 0)) {
strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_VBD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9-]p%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/ram", 8) == 0)) {
strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_PCMCIA_MEM;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/loop", 9) == 0)) {
strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_VBD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu",
- dki_info->dki_dname,
- &dki_info->dki_partition);
+ dki_info->dki_dname,
+ &dki_info->dki_partition);
} else {
strcpy(dki_info->dki_dname, "unknown");
strcpy(dki_info->dki_cname, "unknown");
*/
if (read_disk_info(fd, &capacity, &lbsize) == -1) {
if (efi_debug)
- fprintf(stderr,"unable to read disk info: %d",errno);
+ fprintf(stderr, "unable to read disk info: %d", errno);
errno = EIO;
- return -1;
+ return (-1);
}
switch (cmd) {
if (lbsize == 0) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI assuming "
- "LBA %d bytes\n", DEV_BSIZE);
+ "LBA %d bytes\n", DEV_BSIZE);
lbsize = DEV_BSIZE;
}
if (error == -1) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI lseek "
- "error: %d\n", errno);
- return error;
+ "error: %d\n", errno);
+ return (error);
}
error = read(fd, data, dk_ioc->dki_length);
if (error == -1) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI read "
- "error: %d\n", errno);
- return error;
+ "error: %d\n", errno);
+ return (error);
}
if (error != dk_ioc->dki_length) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI short "
- "read of %d bytes\n", error);
+ "read of %d bytes\n", error);
errno = EIO;
- return -1;
+ return (-1);
}
error = 0;
break;
if (lbsize == 0) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI unknown "
- "LBA size\n");
+ "LBA size\n");
errno = EIO;
- return -1;
+ return (-1);
}
error = lseek(fd, dk_ioc->dki_lba * lbsize, SEEK_SET);
if (error == -1) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI lseek "
- "error: %d\n", errno);
- return error;
+ "error: %d\n", errno);
+ return (error);
}
error = write(fd, data, dk_ioc->dki_length);
if (error == -1) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI write "
- "error: %d\n", errno);
- return error;
+ "error: %d\n", errno);
+ return (error);
}
if (error != dk_ioc->dki_length) {
if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI short "
- "write of %d bytes\n", error);
+ "write of %d bytes\n", error);
errno = EIO;
- return -1;
+ return (-1);
}
/* Sync the new EFI table to disk */
error = fsync(fd);
if (error == -1)
- return error;
+ return (error);
/* Ensure any local disk cache is also flushed */
if (ioctl(fd, BLKFLSBUF, 0) == -1)
- return error;
+ return (error);
error = 0;
break;
(void) fprintf(stderr, "unsupported ioctl()\n");
errno = EIO;
- return -1;
+ return (-1);
}
#else
dk_ioc->dki_data_64 = (uint64_t)(uintptr_t)data;
return (error);
}
-int efi_rescan(int fd)
+int
+efi_rescan(int fd)
{
#if defined(__linux__)
int retry = 5;
while ((error = ioctl(fd, BLKRRPART)) != 0) {
if (--retry == 0) {
(void) fprintf(stderr, "the kernel failed to rescan "
- "the partition table: %d\n", errno);
+ "the partition table: %d\n", errno);
return (-1);
}
}
efi->efi_gpt_HeaderCRC32 = 0;
len_t headerSize = (len_t)LE_32(efi->efi_gpt_HeaderSize);
- if(headerSize < EFI_MIN_LABEL_SIZE || headerSize > EFI_LABEL_SIZE) {
+ if (headerSize < EFI_MIN_LABEL_SIZE || headerSize > EFI_LABEL_SIZE) {
if (efi_debug)
(void) fprintf(stderr,
"Invalid EFI HeaderSize %llu. Assuming %d.\n",
* get the partition number for this file descriptor.
*/
if ((rval = efi_get_info(fd, &dki_info)) != 0)
- return rval;
+ return (rval);
if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) &&
(strncmp(dki_info.dki_dname, "md", 3) == 0)) {
if (read_disk_info(fd, &capacity, &lbsize) == -1) {
if (efi_debug) {
(void) fprintf(stderr,
- "unable to read disk info: %d",
- errno);
+ "unable to read disk info: %d",
+ errno);
}
return (VT_EINVAL);
}
}
if (posix_memalign((void **)&dk_ioc.dki_data,
- disk_info.dki_lbsize, label_len))
+ disk_info.dki_lbsize, label_len))
return (VT_ERROR);
memset(dk_ioc.dki_data, 0, label_len);
diskaddr_t lba_backup_gpt_hdr;
if ((rval = efi_get_info(fd, &dki_info)) != 0)
- return rval;
+ return (rval);
/* check if we are dealing wih a metadevice */
if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) &&
*/
lba_backup_gpt_hdr = vtoc->efi_last_u_lba + 1 + nblocks;
if (posix_memalign((void **)&dk_ioc.dki_data,
- vtoc->efi_lbasize, dk_ioc.dki_length))
+ vtoc->efi_lbasize, dk_ioc.dki_length))
return (VT_ERROR);
memset(dk_ioc.dki_data, 0, dk_ioc.dki_length);
fstype = calloc(sizeof (sa_fstype_t), 1);
if (fstype == NULL)
- return NULL;
+ return (NULL);
fstype->name = name;
fstype->ops = ops;
fstype->next = fstypes;
fstypes = fstype;
- return fstype;
+ return (fstype);
}
sa_handle_t
impl_handle = calloc(sizeof (struct sa_handle_impl), 1);
if (impl_handle == NULL)
- return NULL;
+ return (NULL);
impl_handle->zfs_libhandle = libzfs_init();
if (type == ZFS_TYPE_FILESYSTEM &&
zfs_iter_filesystems(zhp, update_zfs_shares_cb, pcookie) != 0) {
zfs_close(zhp);
- return 1;
+ return (1);
}
if (type != ZFS_TYPE_FILESYSTEM) {
zfs_close(zhp);
- return 0;
+ return (0);
}
if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint,
sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) {
zfs_close(zhp);
- return 0;
+ return (0);
}
dataset = (char *)zfs_get_name(zhp);
if (dataset == NULL) {
zfs_close(zhp);
- return 0;
+ return (0);
}
if (!zfs_is_mounted(zhp, NULL)) {
zfs_close(zhp);
- return 0;
+ return (0);
}
if ((udata->proto == NULL || strcmp(udata->proto, "nfs") == 0) &&
zfs_close(zhp);
- return 0;
+ return (0);
}
static int
update_cookie_t udata;
if (impl_handle->zfs_libhandle == NULL)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
assert(impl_share->dataset != NULL);
ZFS_TYPE_FILESYSTEM);
if (zhp == NULL)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
udata.handle = impl_handle;
udata.proto = proto;
(void) update_zfs_shares_cb(zhp, &udata);
- return SA_OK;
+ return (SA_OK);
}
static int
update_cookie_t udata;
if (impl_handle->zfs_libhandle == NULL)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
udata.handle = impl_handle;
udata.proto = proto;
(void) zfs_iter_root(impl_handle->zfs_libhandle, update_zfs_shares_cb,
&udata);
- return SA_OK;
+ return (SA_OK);
}
static int
if (impl_share == NULL) {
if (lstat(pathname, &statbuf) != 0 ||
!S_ISDIR(statbuf.st_mode))
- return SA_BAD_PATH;
+ return (SA_BAD_PATH);
impl_share = alloc_share(pathname);
free_share(impl_share);
}
- return rc;
+ return (rc);
}
void
impl_share = impl_share->next;
}
- return impl_share;
+ return (impl_share);
}
sa_share_t
sa_find_share(sa_handle_t handle, char *sharepath)
{
- return (sa_share_t)find_share((sa_handle_impl_t)handle, sharepath);
+ return ((sa_share_t)find_share((sa_handle_impl_t)handle, sharepath));
}
int
continue;
}
- return fstype->ops->validate_shareopts(options);
+ return (fstype->ops->validate_shareopts(options));
}
- return SA_INVALID_PROTOCOL;
+ return (SA_INVALID_PROTOCOL);
}
boolean_t
sa_needs_refresh(sa_handle_t handle)
{
- return B_TRUE;
+ return (B_TRUE);
}
libzfs_handle_t *
sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
if (impl_handle == NULL)
- return NULL;
+ return (NULL);
- return impl_handle->zfs_libhandle;
+ return (impl_handle->zfs_libhandle);
}
static sa_share_impl_t
impl_share = calloc(sizeof (struct sa_share_impl), 1);
if (impl_share == NULL)
- return NULL;
+ return (NULL);
impl_share->sharepath = strdup(sharepath);
if (impl_share->sharepath == NULL) {
free(impl_share);
- return NULL;
+ return (NULL);
}
impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count);
if (impl_share->fsinfo == NULL) {
free(impl_share->sharepath);
free(impl_share);
- return NULL;
+ return (NULL);
}
- return impl_share;
+ return (impl_share);
}
static void
shareopts, sourcestr, dataset);
#endif
- return process_share(impl_handle, impl_share, mountpoint, NULL,
- proto, shareopts, NULL, dataset, B_FALSE);
+ return (process_share(impl_handle, impl_share, mountpoint, NULL,
+ proto, shareopts, NULL, dataset, B_FALSE));
}
void
sa_share_fsinfo_t *fsinfo; /* per-fstype information */
} *sa_share_impl_t;
-#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index]))
+#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index]))
typedef struct sa_share_ops {
int (*enable_share)(sa_share_impl_t share);
typedef int (*nfs_host_callback_t)(const char *sharepath, const char *host,
const char *security, const char *access, void *cookie);
-/**
+/*
* Invokes the specified callback function for each Solaris share option
* listed in the specified string.
*/
int was_nul, rc;
if (shareopts == NULL)
- return SA_OK;
+ return (SA_OK);
shareopts_dup = strdup(shareopts);
if (shareopts_dup == NULL)
- return SA_NO_MEMORY;
+ return (SA_NO_MEMORY);
opt = shareopts_dup;
was_nul = 0;
if (rc != SA_OK) {
free(shareopts_dup);
- return rc;
+ return (rc);
}
}
free(shareopts_dup);
- return 0;
+ return (0);
}
typedef struct nfs_host_cookie_s {
const char *security;
} nfs_host_cookie_t;
-/**
+/*
* Helper function for foreach_nfs_host. This function checks whether the
* current share option is a host specification and invokes a callback
* function with information about the host.
host_dup = strdup(value);
if (host_dup == NULL)
- return SA_NO_MEMORY;
+ return (SA_NO_MEMORY);
host = host_dup;
if (rc != SA_OK) {
free(host_dup);
- return rc;
+ return (rc);
}
host = next;
free(host_dup);
}
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Invokes a callback function for all NFS hosts that are set for a share.
*/
static int
&udata);
}
-/**
+/*
* Converts a Solaris NFS host specification to its Linux equivalent.
*/
static int
}
if (*plinux_hostspec == NULL) {
- return SA_NO_MEMORY;
+ return (SA_NO_MEMORY);
}
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Used internally by nfs_enable_share to enable sharing for a single host.
*/
static int
free(opts);
if (rc < 0)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
else
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Adds a Linux share option to an array of NFS options.
*/
static int
(value ? 1 + strlen(value) : 0) + 1);
if (new_linux_opts == NULL)
- return SA_NO_MEMORY;
+ return (SA_NO_MEMORY);
new_linux_opts[len] = '\0';
*plinux_opts = new_linux_opts;
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Validates and converts a single Solaris share option to its Linux
* equivalent.
*/
/* host-specific options, these are taken care of elsewhere */
if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 ||
strcmp(key, "sec") == 0)
- return SA_OK;
+ return (SA_OK);
if (strcmp(key, "anon") == 0)
key = "anonuid";
- if (strcmp(key, "root_mapping") == 0) {
- (void) add_linux_shareopt(plinux_opts, "root_squash", NULL);
- key = "anonuid";
- }
+ if (strcmp(key, "root_mapping") == 0) {
+ (void) add_linux_shareopt(plinux_opts, "root_squash", NULL);
+ key = "anonuid";
+ }
if (strcmp(key, "nosub") == 0)
key = "subtree_check";
strcmp(key, "all_squash") != 0 &&
strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 &&
strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) {
- return SA_SYNTAX_ERR;
+ return (SA_SYNTAX_ERR);
}
(void) add_linux_shareopt(plinux_opts, key, value);
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Takes a string containing Solaris share options (e.g. "sync,no_acl") and
* converts them to a NULL-terminated array of Linux NFS options.
*/
(void) add_linux_shareopt(plinux_opts, "no_root_squash", NULL);
(void) add_linux_shareopt(plinux_opts, "mountpoint", NULL);
- rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb, plinux_opts);
+ rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb,
+ plinux_opts);
if (rc != SA_OK) {
free(*plinux_opts);
*plinux_opts = NULL;
}
- return rc;
+ return (rc);
}
-/**
+/*
* Enables NFS sharing for the specified share.
*/
static int
int rc;
if (!nfs_available()) {
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
}
shareopts = FSINFO(impl_share, nfs_fstype)->shareopts;
if (shareopts == NULL)
- return SA_OK;
+ return (SA_OK);
rc = get_linux_shareopts(shareopts, &linux_opts);
if (rc != SA_OK)
- return rc;
+ return (rc);
rc = foreach_nfs_host(impl_share, nfs_enable_share_one, linux_opts);
free(linux_opts);
- return rc;
+ return (rc);
}
-/**
+/*
* Used internally by nfs_disable_share to disable sharing for a single host.
*/
static int
free(hostpath);
if (rc < 0)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
else
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Disables NFS sharing for the specified share.
*/
static int
* The share can't possibly be active, so nothing
* needs to be done to disable it.
*/
- return SA_OK;
+ return (SA_OK);
}
- return foreach_nfs_host(impl_share, nfs_disable_share_one, NULL);
+ return (foreach_nfs_host(impl_share, nfs_disable_share_one, NULL));
}
-/**
+/*
* Checks whether the specified NFS share options are syntactically correct.
*/
static int
rc = get_linux_shareopts(shareopts, &linux_opts);
if (rc != SA_OK)
- return rc;
+ return (rc);
free(linux_opts);
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Checks whether a share is currently active.
*/
static boolean_t
FILE *nfs_exportfs_temp_fp;
if (!nfs_available())
- return B_FALSE;
+ return (B_FALSE);
nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r");
if (nfs_exportfs_temp_fp == NULL ||
fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) {
fclose(nfs_exportfs_temp_fp);
- return B_FALSE;
+ return (B_FALSE);
}
- while (fgets(line, sizeof(line), nfs_exportfs_temp_fp) != NULL) {
+ while (fgets(line, sizeof (line), nfs_exportfs_temp_fp) != NULL) {
/*
* exportfs uses separate lines for the share path
* and the export options when the share path is longer
if (strcmp(line, impl_share->sharepath) == 0) {
fclose(nfs_exportfs_temp_fp);
- return B_TRUE;
+ return (B_TRUE);
}
}
fclose(nfs_exportfs_temp_fp);
- return B_FALSE;
+ return (B_FALSE);
}
-/**
+/*
* Called to update a share's options. A share's options might be out of
* date if the share was loaded from disk (i.e. /etc/dfs/sharetab) and the
* "sharenfs" dataset property has changed in the meantime. This function
shareopts_dup = strdup(shareopts);
if (shareopts_dup == NULL)
- return SA_NO_MEMORY;
+ return (SA_NO_MEMORY);
if (old_shareopts != NULL)
free(old_shareopts);
if (needs_reshare)
nfs_enable_share(impl_share);
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Clears a share's NFS options. Used by libshare to
* clean up shares that are about to be free()'d.
*/
nfs_exportfs_temp_fd = mkstemp(nfs_exportfs_tempfile);
if (nfs_exportfs_temp_fd < 0)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
unlink(nfs_exportfs_tempfile);
if (pid < 0) {
(void) close(nfs_exportfs_temp_fd);
nfs_exportfs_temp_fd = -1;
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
}
if (pid > 0) {
- while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR)
- ; /* empty loop body */
+ while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR);
if (rc <= 0) {
(void) close(nfs_exportfs_temp_fd);
nfs_exportfs_temp_fd = -1;
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
}
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
(void) close(nfs_exportfs_temp_fd);
nfs_exportfs_temp_fd = -1;
- return SA_CONFIG_ERR;
+ return (SA_CONFIG_ERR);
}
- return SA_OK;
+ return (SA_OK);
}
/* child */
if (nfs_exportfs_temp_fd == -1)
(void) nfs_check_exportfs();
- return (nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE;
+ return ((nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE);
}
-/**
+/*
* Initializes the NFS functionality of libshare.
*/
void
*
* This is an addition to the zfs device driver to add, modify and remove SMB
* shares using the 'net share' command that comes with Samba.
-
+ *
* TESTING
* Make sure that samba listens to 'localhost' (127.0.0.1) and that the options
* 'usershare max shares' and 'usershare owner only' have been rewied/set
static sa_fstype_t *smb_fstype;
-/**
+/*
* Retrieve the list of SMB shares.
*/
static int
/* opendir(), stat() */
shares_dir = opendir(SHARE_DIR);
if (shares_dir == NULL)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
/* Go through the directory, looking for shares */
while ((directory = readdir(shares_dir))) {
continue;
snprintf(file_path, sizeof (file_path),
- "%s/%s", SHARE_DIR, directory->d_name);
+ "%s/%s", SHARE_DIR, directory->d_name);
if (stat(file_path, &eStat) == -1) {
rc = SA_SYSTEM_ERR;
name = strdup(directory->d_name);
if (name == NULL) {
- rc = SA_NO_MEMORY;
- goto out;
+ rc = SA_NO_MEMORY;
+ goto out;
}
- while (fgets(line, sizeof(line), share_file_fp)) {
+ while (fgets(line, sizeof (line), share_file_fp)) {
if (line[0] == '#')
continue;
/* Trim trailing new-line character(s). */
while (line[strlen(line) - 1] == '\r' ||
- line[strlen(line) - 1] == '\n')
+ line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
/* Split the line in two, separated by '=' */
strncpy(shares->name, name,
sizeof (shares->name));
- shares->name [sizeof(shares->name)-1] = '\0';
+ shares->name [sizeof (shares->name) - 1] = '\0';
strncpy(shares->path, path,
- sizeof (shares->path));
- shares->path [sizeof(shares->path)-1] = '\0';
+ sizeof (shares->path));
+ shares->path [sizeof (shares->path) - 1] = '\0';
strncpy(shares->comment, comment,
- sizeof (shares->comment));
- shares->comment[sizeof(shares->comment)-1]='\0';
+ sizeof (shares->comment));
+ shares->comment[sizeof (shares->comment)-1] =
+ '\0';
shares->guest_ok = atoi(guest_ok);
shares->next = new_shares;
new_shares = shares;
- name = NULL;
- path = NULL;
- comment = NULL;
+ name = NULL;
+ path = NULL;
+ comment = NULL;
guest_ok = NULL;
}
}
smb_shares = new_shares;
- return rc;
+ return (rc);
}
-/**
+/*
* Used internally by smb_enable_share to enable sharing for a single host.
*/
static int
int rc;
/* Support ZFS share name regexp '[[:alnum:]_-.: ]' */
- strncpy(name, sharename, sizeof(name));
- name [sizeof(name)-1] = '\0';
+ strncpy(name, sharename, sizeof (name));
+ name [sizeof (name)-1] = '\0';
pos = name;
while (*pos != '\0') {
++pos;
}
- /* CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \
- * "Comment" "Everyone:F" */
- snprintf(comment, sizeof(comment), "Comment: %s", sharepath);
-
- argv[0] = NET_CMD_PATH;
- argv[1] = (char*)"-S";
- argv[2] = NET_CMD_ARG_HOST;
- argv[3] = (char*)"usershare";
- argv[4] = (char*)"add";
- argv[5] = (char*)name;
- argv[6] = (char*)sharepath;
- argv[7] = (char*)comment;
+ /*
+ * CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \
+ * "Comment" "Everyone:F"
+ */
+ snprintf(comment, sizeof (comment), "Comment: %s", sharepath);
+
+ argv[0] = NET_CMD_PATH;
+ argv[1] = (char *)"-S";
+ argv[2] = NET_CMD_ARG_HOST;
+ argv[3] = (char *)"usershare";
+ argv[4] = (char *)"add";
+ argv[5] = (char *)name;
+ argv[6] = (char *)sharepath;
+ argv[7] = (char *)comment;
argv[8] = "Everyone:F";
argv[9] = NULL;
rc = libzfs_run_process(argv[0], argv, 0);
if (rc < 0)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
/* Reload the share file */
(void) smb_retrieve_shares();
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Enables SMB sharing for the specified share.
*/
static int
char *shareopts;
if (!smb_available())
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
shareopts = FSINFO(impl_share, smb_fstype)->shareopts;
if (shareopts == NULL) /* on/off */
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
if (strcmp(shareopts, "off") == 0)
- return SA_OK;
+ return (SA_OK);
/* Magic: Enable (i.e., 'create new') share */
- return smb_enable_share_one(impl_share->dataset, impl_share->sharepath);
+ return (smb_enable_share_one(impl_share->dataset,
+ impl_share->sharepath));
}
-/**
+/*
* Used internally by smb_disable_share to disable sharing for a single host.
*/
static int
/* CMD: net -S NET_CMD_ARG_HOST usershare delete Test1 */
argv[0] = NET_CMD_PATH;
- argv[1] = (char*)"-S";
+ argv[1] = (char *)"-S";
argv[2] = NET_CMD_ARG_HOST;
- argv[3] = (char*)"usershare";
- argv[4] = (char*)"delete";
+ argv[3] = (char *)"usershare";
+ argv[4] = (char *)"delete";
argv[5] = strdup(sharename);
argv[6] = NULL;
rc = libzfs_run_process(argv[0], argv, 0);
if (rc < 0)
- return SA_SYSTEM_ERR;
+ return (SA_SYSTEM_ERR);
else
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Disables SMB sharing for the specified share.
*/
static int
* The share can't possibly be active, so nothing
* needs to be done to disable it.
*/
- return SA_OK;
+ return (SA_OK);
}
while (shares != NULL) {
if (strcmp(impl_share->sharepath, shares->path) == 0)
- return smb_disable_share_one(shares->name);
+ return (smb_disable_share_one(shares->name));
shares = shares->next;
}
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Checks whether the specified SMB share options are syntactically correct.
*/
static int
{
/* TODO: Accept 'name' and sec/acl (?) */
if ((strcmp(shareopts, "off") == 0) || (strcmp(shareopts, "on") == 0))
- return SA_OK;
+ return (SA_OK);
- return SA_SYNTAX_ERR;
+ return (SA_SYNTAX_ERR);
}
-/**
+/*
* Checks whether a share is currently active.
*/
static boolean_t
smb_is_share_active(sa_share_impl_t impl_share)
{
if (!smb_available())
- return B_FALSE;
+ return (B_FALSE);
/* Retrieve the list of (possible) active shares */
smb_retrieve_shares();
while (smb_shares != NULL) {
if (strcmp(impl_share->sharepath, smb_shares->path) == 0)
- return B_TRUE;
+ return (B_TRUE);
smb_shares = smb_shares->next;
}
- return B_FALSE;
+ return (B_FALSE);
}
-/**
+/*
* Called to update a share's options. A share's options might be out of
* date if the share was loaded from disk and the "sharesmb" dataset
* property has changed in the meantime. This function also takes care
boolean_t needs_reshare = B_FALSE;
char *old_shareopts;
- if(!impl_share)
- return SA_SYSTEM_ERR;
+ if (!impl_share)
+ return (SA_SYSTEM_ERR);
FSINFO(impl_share, smb_fstype)->active =
smb_is_share_active(impl_share);
shareopts_dup = strdup(shareopts);
if (shareopts_dup == NULL)
- return SA_NO_MEMORY;
+ return (SA_NO_MEMORY);
if (old_shareopts != NULL)
free(old_shareopts);
if (needs_reshare)
smb_enable_share(impl_share);
- return SA_OK;
+ return (SA_OK);
}
-/**
+/*
* Clears a share's SMB options. Used by libshare to
* clean up shares that are about to be free()'d.
*/
if (lstat(SHARE_DIR, &statbuf) != 0 ||
!S_ISDIR(statbuf.st_mode))
- return B_FALSE;
+ return (B_FALSE);
if (access(NET_CMD_PATH, F_OK) != 0)
- return B_FALSE;
+ return (B_FALSE);
- return B_TRUE;
+ return (B_TRUE);
}
-/**
+/*
* Initializes the SMB functionality of libshare.
*/
void
* references are hard to find.
*/
-#define SMB_NAME_MAX 255
-#define SMB_COMMENT_MAX 255
+#define SMB_NAME_MAX 255
+#define SMB_COMMENT_MAX 255
-#define SHARE_DIR "/var/lib/samba/usershares"
-#define NET_CMD_PATH "/usr/bin/net"
-#define NET_CMD_ARG_HOST "127.0.0.1"
+#define SHARE_DIR "/var/lib/samba/usershares"
+#define NET_CMD_PATH "/usr/bin/net"
+#define NET_CMD_ARG_HOST "127.0.0.1"
typedef struct smb_share_s {
char name[SMB_NAME_MAX]; /* Share name */
* Theses are the void returning variants
*/
-#define ATOMIC_INC(name, type) \
+#define ATOMIC_INC(name, type) \
void atomic_inc_##name(volatile type *target) \
{ \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
ATOMIC_INC(64, uint64_t)
-#define ATOMIC_DEC(name, type) \
+#define ATOMIC_DEC(name, type) \
void atomic_dec_##name(volatile type *target) \
{ \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
ATOMIC_DEC(64, uint64_t)
-#define ATOMIC_ADD(name, type1, type2) \
+#define ATOMIC_ADD(name, type1, type2) \
void atomic_add_##name(volatile type1 *target, type2 bits) \
{ \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
ATOMIC_ADD(long, ulong_t, long)
ATOMIC_ADD(64, uint64_t, int64_t)
-void atomic_add_ptr(volatile void *target, ssize_t bits)
+void
+atomic_add_ptr(volatile void *target, ssize_t bits)
{
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0);
*(caddr_t *)target += bits;
}
-#define ATOMIC_SUB(name, type1, type2) \
+#define ATOMIC_SUB(name, type1, type2) \
void atomic_sub_##name(volatile type1 *target, type2 bits) \
{ \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
ATOMIC_SUB(long, ulong_t, long)
ATOMIC_SUB(64, uint64_t, int64_t)
-void atomic_sub_ptr(volatile void *target, ssize_t bits)
+void
+atomic_sub_ptr(volatile void *target, ssize_t bits)
{
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0);
*(caddr_t *)target -= bits;
}
-#define ATOMIC_OR(name, type) \
+#define ATOMIC_OR(name, type) \
void atomic_or_##name(volatile type *target, type bits) \
{ \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
ATOMIC_OR(64, uint64_t)
-#define ATOMIC_AND(name, type) \
+#define ATOMIC_AND(name, type) \
void atomic_and_##name(volatile type *target, type bits) \
{ \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
* New value returning variants
*/
-#define ATOMIC_INC_NV(name, type) \
+#define ATOMIC_INC_NV(name, type) \
type atomic_inc_##name##_nv(volatile type *target) \
{ \
type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (++(*target)); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return rc; \
+ return (rc); \
}
ATOMIC_INC_NV(long, unsigned long)
ATOMIC_INC_NV(64, uint64_t)
-#define ATOMIC_DEC_NV(name, type) \
+#define ATOMIC_DEC_NV(name, type) \
type atomic_dec_##name##_nv(volatile type *target) \
{ \
type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (--(*target)); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return rc; \
+ return (rc); \
}
ATOMIC_DEC_NV(long, unsigned long)
ATOMIC_DEC_NV(64, uint64_t)
-#define ATOMIC_ADD_NV(name, type1, type2) \
+#define ATOMIC_ADD_NV(name, type1, type2) \
type1 atomic_add_##name##_nv(volatile type1 *target, type2 bits)\
{ \
type1 rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target += bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return rc; \
+ return (rc); \
}
ATOMIC_ADD_NV(8, uint8_t, int8_t)
ATOMIC_ADD_NV(long, ulong_t, long)
ATOMIC_ADD_NV(64, uint64_t, int64_t)
-void *atomic_add_ptr_nv(volatile void *target, ssize_t bits)
+void *
+atomic_add_ptr_nv(volatile void *target, ssize_t bits)
{
void *ptr;
ptr = (*(caddr_t *)target += bits);
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return ptr;
+ return (ptr);
}
-#define ATOMIC_SUB_NV(name, type1, type2) \
+#define ATOMIC_SUB_NV(name, type1, type2) \
type1 atomic_sub_##name##_nv(volatile type1 *target, type2 bits)\
{ \
type1 rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target -= bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return rc; \
+ return (rc); \
}
ATOMIC_SUB_NV(8, uint8_t, int8_t)
ATOMIC_SUB_NV(long, ulong_t, long)
ATOMIC_SUB_NV(64, uint64_t, int64_t)
-void *atomic_sub_ptr_nv(volatile void *target, ssize_t bits)
+void *
+atomic_sub_ptr_nv(volatile void *target, ssize_t bits)
{
void *ptr;
ptr = (*(caddr_t *)target -= bits);
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return ptr;
+ return (ptr);
}
-#define ATOMIC_OR_NV(name, type) \
+#define ATOMIC_OR_NV(name, type) \
type atomic_or_##name##_nv(volatile type *target, type bits) \
{ \
type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target |= bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return rc; \
+ return (rc); \
}
ATOMIC_OR_NV(long, unsigned long)
ATOMIC_OR_NV(64, uint64_t)
-#define ATOMIC_AND_NV(name, type) \
+#define ATOMIC_AND_NV(name, type) \
type atomic_and_##name##_nv(volatile type *target, type bits) \
{ \
type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target &= bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return rc; \
+ return (rc); \
}
ATOMIC_AND_NV(long, unsigned long)
* If *arg1 == arg2, set *arg1 = arg3; return old value
*/
-#define ATOMIC_CAS(name, type) \
+#define ATOMIC_CAS(name, type) \
type atomic_cas_##name(volatile type *target, type arg1, type arg2) \
{ \
type old; \
if (old == arg1) \
*target = arg2; \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return old; \
+ return (old); \
}
ATOMIC_CAS(8, uint8_t)
ATOMIC_CAS(ulong, ulong_t)
ATOMIC_CAS(64, uint64_t)
-void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2)
+void *
+atomic_cas_ptr(volatile void *target, void *arg1, void *arg2)
{
void *old;
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0);
old = *(void **)target;
- if (old == arg1)
- *(void **)target = arg2;
+ if (old == arg1)
+ *(void **)target = arg2;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return old;
+ return (old);
}
* Swap target and return old value
*/
-#define ATOMIC_SWAP(name, type) \
+#define ATOMIC_SWAP(name, type) \
type atomic_swap_##name(volatile type *target, type bits) \
{ \
type old; \
old = *target; \
*target = bits; \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
- return old; \
+ return (old); \
}
ATOMIC_SWAP(8, uint8_t)
ATOMIC_SWAP(ulong, ulong_t)
ATOMIC_SWAP(64, uint64_t)
-void *atomic_swap_ptr(volatile void *target, void *bits)
+void *
+atomic_swap_ptr(volatile void *target, void *bits)
{
void *old;
*(void **)target = bits;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return old;
+ return (old);
}
-int atomic_set_long_excl(volatile ulong_t *target, uint_t value)
+int
+atomic_set_long_excl(volatile ulong_t *target, uint_t value)
{
ulong_t bit;
bit = (1UL << value);
if ((*target & bit) != 0) {
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return -1;
+ return (-1);
}
*target |= bit;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return 0;
+ return (0);
}
-int atomic_clear_long_excl(volatile ulong_t *target, uint_t value)
+int
+atomic_clear_long_excl(volatile ulong_t *target, uint_t value)
{
ulong_t bit;
bit = (1UL << value);
if ((*target & bit) != 0) {
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return -1;
+ return (-1);
}
*target &= ~bit;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
- return 0;
+ return (0);
}
-void membar_enter(void)
+void
+membar_enter(void)
{
/* XXX - Implement me */
}
-void membar_exit(void)
+void
+membar_exit(void)
{
/* XXX - Implement me */
}
-void membar_producer(void)
+void
+membar_producer(void)
{
/* XXX - Implement me */
}
-void membar_consumer(void)
+void
+membar_consumer(void)
{
/* XXX - Implement me */
}
/* Legacy kernel interfaces; they will go away (eventually). */
-uint8_t cas8(uint8_t *target, uint8_t arg1, uint8_t arg2)
+uint8_t
+cas8(uint8_t *target, uint8_t arg1, uint8_t arg2)
{
- return atomic_cas_8(target, arg1, arg2);
+ return (atomic_cas_8(target, arg1, arg2));
}
-uint32_t cas32(uint32_t *target, uint32_t arg1, uint32_t arg2)
+uint32_t
+cas32(uint32_t *target, uint32_t arg1, uint32_t arg2)
{
- return atomic_cas_32(target, arg1, arg2);
+ return (atomic_cas_32(target, arg1, arg2));
}
-uint64_t cas64(uint64_t *target, uint64_t arg1, uint64_t arg2)
+uint64_t
+cas64(uint64_t *target, uint64_t arg1, uint64_t arg2)
{
- return atomic_cas_64(target, arg1, arg2);
+ return (atomic_cas_64(target, arg1, arg2));
}
-ulong_t caslong(ulong_t *target, ulong_t arg1, ulong_t arg2)
+ulong_t
+caslong(ulong_t *target, ulong_t arg1, ulong_t arg2)
{
- return atomic_cas_ulong(target, arg1, arg2);
+ return (atomic_cas_ulong(target, arg1, arg2));
}
-void *casptr(void *target, void *arg1, void *arg2)
+void *
+casptr(void *target, void *arg1, void *arg2)
{
- return atomic_cas_ptr(target, arg1, arg2);
+ return (atomic_cas_ptr(target, arg1, arg2));
}
-void atomic_and_long(ulong_t *target, ulong_t bits)
+void
+atomic_and_long(ulong_t *target, ulong_t bits)
{
- return atomic_and_ulong(target, bits);
+ return (atomic_and_ulong(target, bits));
}
-void atomic_or_long(ulong_t *target, ulong_t bits)
+void
+atomic_or_long(ulong_t *target, ulong_t bits)
{
- return atomic_or_ulong(target, bits);
+ return (atomic_or_ulong(target, bits));
}
pthread_mutex_lock(&mtx);
if (strlen(execname) == 0) {
- rc = readlink("/proc/self/exe", execname, sizeof(execname) - 1);
+ rc = readlink("/proc/self/exe",
+ execname, sizeof (execname) - 1);
if (rc == -1) {
execname[0] = '\0';
} else {
}
pthread_mutex_unlock(&mtx);
- return ptr;
+ return (ptr);
}
void
gethrestime(timestruc_t *ts)
{
- struct timeval tv;
+ struct timeval tv;
- gettimeofday(&tv, NULL);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
+ gettimeofday(&tv, NULL);
+ ts->tv_sec = tv.tv_sec;
+ ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
}
rc = clock_gettime(CLOCK_MONOTONIC, &ts);
if (rc) {
fprintf(stderr, "Error: clock_gettime() = %d\n", rc);
- abort();
+ abort();
}
- return (((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec;
+ return ((((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec);
}
#include <sys/stat.h>
#include <unistd.h>
-#define BUFSIZE (MNT_LINE_MAX + 2)
+#define BUFSIZE (MNT_LINE_MAX + 2)
__thread char buf[BUFSIZE];
-#define DIFF(xx) ((mrefp->xx != NULL) && \
- (mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0))
+#define DIFF(xx) ( \
+ (mrefp->xx != NULL) && \
+ (mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0))
int
getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp)
{
int ret;
- while (((ret = _sol_getmntent(fp, mgetp)) == 0) &&
- (DIFF(mnt_special) || DIFF(mnt_mountp) ||
- DIFF(mnt_fstype) || DIFF(mnt_mntopts)));
+ while (
+ ((ret = _sol_getmntent(fp, mgetp)) == 0) && (
+ DIFF(mnt_special) || DIFF(mnt_mountp) ||
+ DIFF(mnt_fstype) || DIFF(mnt_mntopts)));
- return ret;
+ return (ret);
}
int
mgetp->mnt_mountp = mntbuf.mnt_dir;
mgetp->mnt_fstype = mntbuf.mnt_type;
mgetp->mnt_mntopts = mntbuf.mnt_opts;
- return 0;
+ return (0);
}
if (feof(fp))
- return -1;
+ return (-1);
- return MNT_TOOLONG;
+ return (MNT_TOOLONG);
}
int
if (stat64(mp->mnt_mountp, &st) != 0) {
mp->mnt_major = 0;
mp->mnt_minor = 0;
- return ret;
+ return (ret);
}
mp->mnt_major = major(st.st_dev);
mp->mnt_minor = minor(st.st_dev);
}
- return ret;
+ return (ret);
}
#include_next <assert.h>
#ifndef _LIBSPL_ASSERT_H
-#define _LIBSPL_ASSERT_H
+#define _LIBSPL_ASSERT_H
#include <stdio.h>
#include <stdlib.h>
*/
#ifndef _LIBSPL_DEVID_H
-#define _LIBSPL_DEVID_H
+#define _LIBSPL_DEVID_H
#include <stdlib.h>
dev_t dev;
} devid_nmlist_t;
-static inline int devid_str_decode(char *devidstr, ddi_devid_t *retdevid, char **retminor_name) { abort(); }
-static inline int devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, char *minor_name, devid_nmlist_t **retlist) { abort(); }
-static inline void devid_str_free(char *str) { abort(); }
-static inline void devid_free(ddi_devid_t devid) { abort(); }
-static inline void devid_free_nmlist(devid_nmlist_t *list) { abort(); }
-static inline int devid_get(int fd, ddi_devid_t *retdevid) { return -1; }
-static inline int devid_get_minor_name(int fd, char **retminor_name) { abort(); }
-static inline char *devid_str_encode(ddi_devid_t devid, char *minor_name) { abort(); }
+static inline
+int
+devid_str_decode(
+ char *devidstr,
+ ddi_devid_t *retdevid,
+ char **retminor_name)
+{
+ abort();
+}
+
+static inline
+int
+devid_deviceid_to_nmlist(
+ char *search_path,
+ ddi_devid_t devid,
+ char *minor_name,
+ devid_nmlist_t **retlist)
+{
+ abort();
+}
+
+static inline
+void
+devid_str_free(char *str)
+{
+ abort();
+}
+
+static inline
+void
+devid_free(ddi_devid_t devid)
+{
+ abort();
+}
+
+static inline
+void
+devid_free_nmlist(devid_nmlist_t *list)
+{
+ abort();
+}
+
+static inline
+int
+devid_get(
+ int fd,
+ ddi_devid_t *retdevid)
+{
+ return (-1);
+}
+
+static inline
+int
+devid_get_minor_name(
+ int fd,
+ char **retminor_name)
+{
+ abort();
+}
+
+static inline
+char *
+devid_str_encode(
+ ddi_devid_t devid,
+ char *minor_name)
+{
+ abort();
+}
#endif
*/
#ifndef _LIBSPL_LIBDEVINFO_H
-#define _LIBSPL_LIBDEVINFO_H
+#define _LIBSPL_LIBDEVINFO_H
#endif /* _LIBSPL_LIBDEVINFO_H */
*/
#ifndef _LIBSPL_LIBGEN_H
-#define _LIBSPL_LIBGEN_H
+#define _LIBSPL_LIBGEN_H
#include <sys/types.h>
* Use is subject to license terms.
*/
#ifndef _LIBSPL_LIBSHARE_H
-#define _LIBSPL_LIBSHARE_H
+#define _LIBSPL_LIBSHARE_H
typedef void *sa_handle_t; /* opaque handle to access core functions */
typedef void *sa_group_t;
#include_next <limits.h>
#ifndef _LIBSPL_LIMITS_H
-#define _LIBSPL_LIMITS_H
+#define _LIBSPL_LIMITS_H
-#define DBL_DIG 15
-#define DBL_MAX 1.7976931348623157081452E+308
-#define DBL_MIN 2.2250738585072013830903E-308
+#define DBL_DIG 15
+#define DBL_MAX 1.7976931348623157081452E+308
+#define DBL_MIN 2.2250738585072013830903E-308
-#define FLT_DIG 6
-#define FLT_MAX 3.4028234663852885981170E+38F
-#define FLT_MIN 1.1754943508222875079688E-38F
+#define FLT_DIG 6
+#define FLT_MAX 3.4028234663852885981170E+38F
+#define FLT_MIN 1.1754943508222875079688E-38F
#endif /* _LIBSPL_LIMITS_H */
#include_next <locale.h>
#ifndef _LIBSPL_LOCALE_H
-#define _LIBSPL_LOCALE_H
+#define _LIBSPL_LOCALE_H
#include <time.h>
#include <sys/time.h>
*/
#ifndef _NOTE_H
-#define _NOTE_H
+#define _NOTE_H
#include <sys/note.h>
extern "C" {
#endif
-#define NOTE _NOTE
+#define NOTE _NOTE
#ifdef __cplusplus
}
*/
#ifndef _LIBSPL_PRIV_H
-#define _LIBSPL_PRIV_H
+#define _LIBSPL_PRIV_H
#include <sys/types.h>
/* Couldn't find this definition in OpenGrok */
-#define PRIV_SYS_CONFIG "sys_config"
+#define PRIV_SYS_CONFIG "sys_config"
/*
* priv_op_t indicates a privilege operation type
*/
#ifndef LIBSPL_RPC_TYPES_H
-#define LIBSPL_RPC_TYPES_H
+#define LIBSPL_RPC_TYPES_H
#include_next <rpc/types.h>
#include <sys/kmem.h>
*/
#ifndef LIBSPL_RPC_XDR_H
-#define LIBSPL_RPC_XDR_H
+#define LIBSPL_RPC_XDR_H
#include_next <rpc/xdr.h>
* XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in
* the XDR stream moving over RDMA.
*/
-#define XDR_PEEK 2
-#define XDR_SKIPBYTES 3
-#define XDR_RDMAGET 4
-#define XDR_RDMASET 5
+#define XDR_PEEK 2
+#define XDR_SKIPBYTES 3
+#define XDR_RDMAGET 4
+#define XDR_RDMASET 5
extern bool_t xdr_control(XDR *xdrs, int request, void *info);
#include_next <stdio.h>
#ifndef _LIBSPL_STDIO_H
-#define _LIBSPL_STDIO_H
+#define _LIBSPL_STDIO_H
-#define enable_extended_FILE_stdio(fd, sig) ((void) 0)
+#define enable_extended_FILE_stdio(fd, sig) ((void) 0)
#endif
#include_next <stdlib.h>
#ifndef _LIBSPL_STDLIB_H
-#define _LIBSPL_STDLIB_H
+#define _LIBSPL_STDLIB_H
extern const char *getexecname(void);
*/
#ifndef _LIBSPL_STRING_H
-#define _LIBSPL_STRING_H
+#define _LIBSPL_STRING_H
#include_next <string.h>
*/
#ifndef _LIBSPL_STRINGS_H
-#define _LIBSPL_STRINGS_H
+#define _LIBSPL_STRINGS_H
#include <string.h>
#include_next <strings.h>
*/
#ifndef _LIBSPL_SYNCH_H
-#define _LIBSPL_SYNCH_H
+#define _LIBSPL_SYNCH_H
#endif
*/
#ifndef _LIBSPL_SYS_BITMAP_H
-#define _LIBSPL_SYS_BITMAP_H
+#define _LIBSPL_SYS_BITMAP_H
#endif
*/
#ifndef _SYS_CALLB_H
-#define _SYS_CALLB_H
+#define _SYS_CALLB_H
#endif
*/
#ifndef _LIBSPL_SYS_CMN_ERR_H
-#define _LIBSPL_SYS_CMN_ERR_H
+#define _LIBSPL_SYS_CMN_ERR_H
#endif
*/
#ifndef _LIBSPL_SYS_COMPRESS_H
-#define _LIBSPL_SYS_COMPRESS_H
+#define _LIBSPL_SYS_COMPRESS_H
#endif /* _LIBSPL_SYS_COMPRESS_H */
*/
#ifndef _LIBSPL_SYS_CRED_H
-#define _LIBSPL_SYS_CRED_H
+#define _LIBSPL_SYS_CRED_H
typedef struct cred cred_t;
*/
#ifndef _LIBSPL_SYS_DEBUG_H
-#define _LIBSPL_SYS_DEBUG_H
+#define _LIBSPL_SYS_DEBUG_H
#include <assert.h>
*/
#ifndef _SYS_FEATURE_TESTS_H
-#define _SYS_FEATURE_TESTS_H
+#define _SYS_FEATURE_TESTS_H
-#define __NORETURN __attribute__((__noreturn__))
+#define __NORETURN __attribute__((__noreturn__))
#endif
*/
#ifndef _LIBSPL_SYS_FILE_H
-#define _LIBSPL_SYS_FILE_H
+#define _LIBSPL_SYS_FILE_H
#include_next <sys/file.h>
#include <sys/user.h>
-#define FREAD 1
-#define FWRITE 2
-//#define FAPPEND 8
+#define FREAD 1
+#define FWRITE 2
+// #define FAPPEND 8
-#define FCREAT O_CREAT
-#define FTRUNC O_TRUNC
-#define FOFFMAX O_LARGEFILE
-#define FSYNC O_SYNC
-#define FDSYNC O_DSYNC
-#define FRSYNC O_RSYNC
-#define FEXCL O_EXCL
+#define FCREAT O_CREAT
+#define FTRUNC O_TRUNC
+#define FOFFMAX O_LARGEFILE
+#define FSYNC O_SYNC
+#define FDSYNC O_DSYNC
+#define FRSYNC O_RSYNC
+#define FEXCL O_EXCL
-#define FNODSYNC 0x10000 /* fsync pseudo flag */
-#define FNOFOLLOW 0x20000 /* don't follow symlinks */
-#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
+#define FNODSYNC 0x10000 /* fsync pseudo flag */
+#define FNOFOLLOW 0x20000 /* don't follow symlinks */
+#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
#endif
*/
#ifndef _SYS_FRAME_H
-#define _SYS_FRAME_H
+#define _SYS_FRAME_H
#include <sys/types.h>
*/
#ifndef _LIBSPL_SYS_INT_LIMITS_H
-#define _LIBSPL_SYS_INT_LIMITS_H
+#define _LIBSPL_SYS_INT_LIMITS_H
#endif
*/
#ifndef _SOL_SYS_INT_TYPES_H
-#define _SOL_SYS_INT_TYPES_H
+#define _SOL_SYS_INT_TYPES_H
#include <inttypes.h>
*/
#ifndef _SOL_SYS_INTTYPES_H
-#define _SOL_SYS_INTTYPES_H
+#define _SOL_SYS_INTTYPES_H
#include <inttypes.h>
-#define _INT64_TYPE
+#define _INT64_TYPE
#endif
#if defined(__x86_64) || defined(__x86_64__)
#if !defined(__x86_64)
-#define __x86_64
+#define __x86_64
#endif
#if !defined(__amd64)
-#define __amd64
+#define __amd64
#endif
#if !defined(__x86)
-#define __x86
+#define __x86
#endif
#if !defined(_LP64)
-#define _LP64
+#define _LP64
#endif
#if !defined(_LITTLE_ENDIAN)
-#define _LITTLE_ENDIAN
+#define _LITTLE_ENDIAN
#endif
-#define _SUNOS_VTOC_16
+#define _SUNOS_VTOC_16
/* i386 arch specific defines */
#elif defined(__i386) || defined(__i386__)
#if !defined(__i386)
-#define __i386
+#define __i386
#endif
#if !defined(__x86)
-#define __x86
+#define __x86
#endif
#if !defined(_ILP32)
-#define _ILP32
+#define _ILP32
#endif
#if !defined(_LITTLE_ENDIAN)
-#define _LITTLE_ENDIAN
+#define _LITTLE_ENDIAN
#endif
-#define _SUNOS_VTOC_16
+#define _SUNOS_VTOC_16
/* powerpc arch specific defines */
#elif defined(__powerpc) || defined(__powerpc__)
#if !defined(__powerpc)
-#define __powerpc
+#define __powerpc
#endif
#if !defined(__powerpc__)
-#define __powerpc__
+#define __powerpc__
#endif
#if !defined(_LP64)
#ifdef __powerpc64__
-#define _LP64
+#define _LP64
#else
-#define _LP32
+#define _LP32
#endif
#endif
#if !defined(_BIG_ENDIAN)
-#define _BIG_ENDIAN
+#define _BIG_ENDIAN
#endif
-#define _SUNOS_VTOC_16
+#define _SUNOS_VTOC_16
/* arm arch specific defines */
#elif defined(__arm) || defined(__arm__)
#if !defined(__arm)
-#define __arm
+#define __arm
#endif
#if !defined(__arm__)
-#define __arm__
+#define __arm__
#endif
#if defined(__ARMEL__)
-#define _LITTLE_ENDIAN
+#define _LITTLE_ENDIAN
#else
-#define _BIG_ENDIAN
+#define _BIG_ENDIAN
#endif
-#define _SUNOS_VTOC_16
+#define _SUNOS_VTOC_16
#else /* Currently only x86_64, i386, arm, and powerpc arches supported */
#error "Unsupported ISA type"
#define KM_SLEEP 0x00000000 /* same as KM_SLEEP */
#define KM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */
-#define kmem_alloc(size, flags) malloc(size)
-#define kmem_free(ptr, size) free(ptr)
+#define kmem_alloc(size, flags) malloc(size)
+#define kmem_free(ptr, size) free(ptr)
#ifdef __cplusplus
}
*/
#ifndef _LIBSPL_SYS_MKDEV_H
-#define _LIBSPL_SYS_MKDEV_H
+#define _LIBSPL_SYS_MKDEV_H
#endif
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
/* Copyright 2006 Ricardo Correia */
#ifndef _SYS_MNTTAB_H
-#define _SYS_MNTTAB_H
+#define _SYS_MNTTAB_H
#include <stdio.h>
#include <mntent.h>
mnt_new.mnt_opts = mnt->mnt_mntopts;
- return hasmntopt(&mnt_new, opt);
+ return (hasmntopt(&mnt_new, opt));
}
-#define hasmntopt _sol_hasmntopt
-#define getmntent _sol_getmntent
+#define hasmntopt _sol_hasmntopt
+#define getmntent _sol_getmntent
#endif
#include_next <sys/mount.h>
#ifndef _LIBSPL_SYS_MOUNT_H
-#define _LIBSPL_SYS_MOUNT_H
+#define _LIBSPL_SYS_MOUNT_H
#include <sys/mntent.h>
#include <assert.h>
* and we don't want to require the kernel headers
*/
#if !defined(BLKGETSIZE64)
-#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
+#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#endif
/*
* headers define MS_DIRSYNC to be S_WRITE.
*/
#if !defined(MS_DIRSYNC)
-#define MS_DIRSYNC S_WRITE
+#define MS_DIRSYNC S_WRITE
#endif
/*
* kernel back to 2.4.11 so we define them correctly if they are missing.
*/
#ifdef MNT_FORCE
-# define MS_FORCE MNT_FORCE
+#define MS_FORCE MNT_FORCE
#else
-# define MS_FORCE 0x00000001
+#define MS_FORCE 0x00000001
#endif /* MNT_FORCE */
#ifdef MNT_DETACH
-# define MS_DETACH MNT_DETACH
+#define MS_DETACH MNT_DETACH
#else
-# define MS_DETACH 0x00000002
+#define MS_DETACH 0x00000002
#endif /* MNT_DETACH */
/*
* compatibility, MS_OVERLAY is defined to explicitly have the user
* provide a flag (-O) to mount over a non empty directory.
*/
-#define MS_OVERLAY 0x00000004
+#define MS_OVERLAY 0x00000004
#endif /* _LIBSPL_SYS_MOUNT_H */
*/
#ifndef _LIBSPL_SYS_PARAM_H
-#define _LIBSPL_SYS_PARAM_H
+#define _LIBSPL_SYS_PARAM_H
#include_next <sys/param.h>
#include <unistd.h>
* Note that the blocked devices are assumed to have DEV_BSIZE
* "sectors" and that fragments must be some multiple of this size.
*/
-#define MAXBSIZE 8192
-#define DEV_BSIZE 512
-#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define MAXBSIZE 8192
+#define DEV_BSIZE 512
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
-#define MAXNAMELEN 256
-#define MAXOFFSET_T LLONG_MAX
+#define MAXNAMELEN 256
+#define MAXOFFSET_T LLONG_MAX
-#define UID_NOBODY 60001 /* user ID no body */
-#define GID_NOBODY UID_NOBODY
-#define UID_NOACCESS 60002 /* user ID no access */
+#define UID_NOBODY 60001 /* user ID no body */
+#define GID_NOBODY UID_NOBODY
+#define UID_NOACCESS 60002 /* user ID no access */
-#define MAXUID UINT32_MAX /* max user id */
-#define MAXPROJID MAXUID /* max project id */
+#define MAXUID UINT32_MAX /* max user id */
+#define MAXPROJID MAXUID /* max project id */
-#define PAGESIZE (sysconf(_SC_PAGESIZE))
+#define PAGESIZE (sysconf(_SC_PAGESIZE))
#endif
*/
#ifndef _LIBSPL_SYS_PRIV_H
-#define _LIBSPL_SYS_PRIV_H
+#define _LIBSPL_SYS_PRIV_H
#endif
*/
#ifndef _LIBSPL_SYS_PROCESSOR_H
-#define _LIBSPL_SYS_PROCESSOR_H
+#define _LIBSPL_SYS_PROCESSOR_H
-#define getcpuid() (-1)
+#define getcpuid() (-1)
typedef int processorid_t;
*/
#ifndef _LIBSPL_SYS_SDT_H
-#define _LIBSPL_SYS_SDT_H
+#define _LIBSPL_SYS_SDT_H
-#define DTRACE_PROBE(a) ((void) 0)
-#define DTRACE_PROBE1(a,b,c) ((void) 0)
-#define DTRACE_PROBE2(a,b,c,d,e) ((void) 0)
-#define DTRACE_PROBE3(a,b,c,d,e,f,g) ((void) 0)
-#define DTRACE_PROBE4(a,b,c,d,e,f,g,h,i) ((void) 0)
+#define DTRACE_PROBE(a) ((void) 0)
+#define DTRACE_PROBE1(a, b, c) ((void) 0)
+#define DTRACE_PROBE2(a, b, c, d, e) ((void) 0)
+#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void) 0)
+#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void) 0)
#endif
* Portions Copyright 2008 Sun Microsystems, Inc. All Rights reserved.
*/
#ifndef _SYS_STACK_H
-#define _SYS_STACK_H
+#define _SYS_STACK_H
#include <pthread.h>
-#define STACK_BIAS 0
+#define STACK_BIAS 0
#ifdef __USE_GNU
rc = pthread_getattr_np(pthread_self(), &attr);
if (rc)
- return rc;
+ return (rc);
rc = pthread_attr_getstack(&attr, &sp->ss_sp, &sp->ss_size);
if (rc == 0)
pthread_attr_destroy(&attr);
- return rc;
+ return (rc);
}
static inline int
rc = stack_getbounds(sp);
if (rc)
- return rc;
+ return (rc);
- /* thr_stksegment() is expected to set sp.ss_sp to the high stack
- * address, but the stack_getbounds() interface is expected to
- * set sp.ss_sp to the low address. Adjust accordingly. */
+ /*
+ * thr_stksegment() is expected to set sp.ss_sp to the high stack
+ * address, but the stack_getbounds() interface is expected to
+ * set sp.ss_sp to the low address. Adjust accordingly.
+ */
sp->ss_sp = (void *)(((uintptr_t)sp->ss_sp) + sp->ss_size);
sp->ss_flags = 0;
- return rc;
+ return (rc);
}
#endif /* __USE_GNU */
*/
#ifndef _LIBSPL_SYS_STAT_H
-#define _LIBSPL_SYS_STAT_H
+#define _LIBSPL_SYS_STAT_H
#include_next <sys/stat.h>
fstat64_blk(int fd, struct stat64 *st)
{
if (fstat64(fd, st) == -1)
- return -1;
+ return (-1);
/* In Linux we need to use an ioctl to get the size of a block device */
if (S_ISBLK(st->st_mode)) {
if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0)
- return -1;
+ return (-1);
}
- return 0;
+ return (0);
}
#endif /* _LIBSPL_SYS_STAT_H */
*/
#ifndef _LIBSPL_SYS_STROPTS_H
-#define _LIBSPL_SYS_STROPTS_H
+#define _LIBSPL_SYS_STROPTS_H
#endif /* _LIBSPL_SYS_STROPTS_H */
*/
#ifndef _LIBSPL_SYS_SYSEVENT_H
-#define _LIBSPL_SYS_SYSEVENT_H
+#define _LIBSPL_SYS_SYSEVENT_H
#endif
*/
#ifndef _LIBSPL_SYS_SYSMACROS_H
-#define _LIBSPL_SYS_SYSMACROS_H
+#define _LIBSPL_SYS_SYSMACROS_H
#include_next <sys/sysmacros.h>
/* common macros */
#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
-#define MAX(a, b) ((a) < (b) ? (b) : (a))
+#define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif
#ifndef ABS
-#define ABS(a) ((a) < 0 ? -(a) : (a))
+#define ABS(a) ((a) < 0 ? -(a) : (a))
#endif
-#define makedevice(maj,min) makedev(maj,min)
-#define _sysconf(a) sysconf(a)
-#define __NORETURN __attribute__ ((noreturn))
+#define makedevice(maj, min) makedev(maj, min)
+#define _sysconf(a) sysconf(a)
+#define __NORETURN __attribute__((noreturn))
/*
* Compatibility macros/typedefs needed for Solaris -> Linux port
*/
-#define P2ALIGN(x, align) ((x) & -(align))
-#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
-#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
-#define P2ROUNDUP_TYPED(x, align, type) \
+#define P2ALIGN(x, align) ((x) & -(align))
+#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
+#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
+#define P2ROUNDUP_TYPED(x, align, type) \
(-(-(type)(x) & -(type)(align)))
-#define P2BOUNDARY(off, len, align) \
+#define P2BOUNDARY(off, len, align) \
(((off) ^ ((off) + (len) - 1)) > (align) - 1)
-#define P2PHASE(x, align) ((x) & ((align) - 1))
-#define P2NPHASE(x, align) (-(x) & ((align) - 1))
-#define P2NPHASE_TYPED(x, align, type) \
+#define P2PHASE(x, align) ((x) & ((align) - 1))
+#define P2NPHASE(x, align) (-(x) & ((align) - 1))
+#define P2NPHASE_TYPED(x, align, type) \
(-(type)(x) & ((type)(align) - 1))
-#define ISP2(x) (((x) & ((x) - 1)) == 0)
-#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
+#define ISP2(x) (((x) & ((x) - 1)) == 0)
+#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
/*
* Typed version of the P2* macros. These macros should be used to ensure
* or
* P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t)
*/
-#define P2ALIGN_TYPED(x, align, type) \
- ((type)(x) & -(type)(align))
-#define P2PHASE_TYPED(x, align, type) \
- ((type)(x) & ((type)(align) - 1))
-#define P2NPHASE_TYPED(x, align, type) \
- (-(type)(x) & ((type)(align) - 1))
-#define P2ROUNDUP_TYPED(x, align, type) \
- (-(-(type)(x) & -(type)(align)))
-#define P2END_TYPED(x, align, type) \
- (-(~(type)(x) & -(type)(align)))
-#define P2PHASEUP_TYPED(x, align, phase, type) \
- ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
-#define P2CROSS_TYPED(x, y, align, type) \
- (((type)(x) ^ (type)(y)) > (type)(align) - 1)
-#define P2SAMEHIGHBIT_TYPED(x, y, type) \
- (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
+#define P2ALIGN_TYPED(x, align, type) \
+ ((type)(x) & -(type)(align))
+#define P2PHASE_TYPED(x, align, type) \
+ ((type)(x) & ((type)(align) - 1))
+#define P2NPHASE_TYPED(x, align, type) \
+ (-(type)(x) & ((type)(align) - 1))
+#define P2ROUNDUP_TYPED(x, align, type) \
+ (-(-(type)(x) & -(type)(align)))
+#define P2END_TYPED(x, align, type) \
+ (-(~(type)(x) & -(type)(align)))
+#define P2PHASEUP_TYPED(x, align, phase, type) \
+ ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
+#define P2CROSS_TYPED(x, y, align, type) \
+ (((type)(x) ^ (type)(y)) > (type)(align) - 1)
+#define P2SAMEHIGHBIT_TYPED(x, y, type) \
+ (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
/* avoid any possibility of clashing with <stddef.h> version */
*/
#ifndef _LIBSPL_SYS_SYSTEMINFO_H
-#define _LIBSPL_SYS_SYSTEMINFO_H
+#define _LIBSPL_SYS_SYSTEMINFO_H
-#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */
-#define HW_HOSTID_LEN 11 /* minimum buffer size needed */
+#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */
+#define HW_HOSTID_LEN 11 /* minimum buffer size needed */
/* to hold a decimal or hex */
/* hostid string */
-#define sysinfo(cmd,buf,cnt) (-1)
+#define sysinfo(cmd, buf, cnt) (-1)
#endif
*/
#ifndef _LIBSPL_SYS_SYSTM_H
-#define _LIBSPL_SYS_SYSTM_H
+#define _LIBSPL_SYS_SYSTM_H
#endif /* _LIBSPL_SYS_SYSTM_H */
*/
#ifndef _LIBSPL_SYS_TIME_H
-#define _LIBSPL_SYS_TIME_H
+#define _LIBSPL_SYS_TIME_H
#include_next <sys/time.h>
#include <sys/types.h>
#ifndef SEC
-#define SEC 1
+#define SEC 1
#endif
#ifndef MILLISEC
-#define MILLISEC 1000
+#define MILLISEC 1000
#endif
#ifndef MICROSEC
-#define MICROSEC 1000000
+#define MICROSEC 1000000
#endif
#ifndef NANOSEC
-#define NANOSEC 1000000000
+#define NANOSEC 1000000000
#endif
#ifndef NSEC_PER_USEC
-#define NSEC_PER_USEC 1000L
+#define NSEC_PER_USEC 1000L
#endif
#ifndef MSEC2NSEC
-#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
+#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
#endif
#ifndef NSEC2MSEC
-#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
+#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
#endif
extern hrtime_t gethrtime(void);
*/
#ifndef _LIBSPL_SYS_TYPES_H
-#define _LIBSPL_SYS_TYPES_H
+#define _LIBSPL_SYS_TYPES_H
#include <sys/isa_defs.h>
#include <sys/feature_tests.h>
typedef u_longlong_t len_t;
typedef longlong_t diskaddr_t;
-typedef ulong_t pfn_t; /* page frame number */
-typedef ulong_t pgcnt_t; /* number of pages */
-typedef long spgcnt_t; /* signed number of pages */
+typedef ulong_t pfn_t; /* page frame number */
+typedef ulong_t pgcnt_t; /* number of pages */
+typedef long spgcnt_t; /* signed number of pages */
typedef longlong_t hrtime_t;
typedef struct timespec timestruc_t;
typedef struct iovec iovec_t;
typedef enum uio_rw {
- UIO_READ = 0,
- UIO_WRITE = 1,
+ UIO_READ = 0,
+ UIO_WRITE = 1,
} uio_rw_t;
typedef enum uio_seg {
- UIO_USERSPACE = 0,
- UIO_SYSSPACE = 1,
- UIO_USERISPACE= 2,
+ UIO_USERSPACE = 0,
+ UIO_SYSSPACE = 1,
+ UIO_USERISPACE = 2,
} uio_seg_t;
typedef struct uio {
} xu_ext;
} xuio_t;
-#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
-#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
+#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
+#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
#endif /* _SYS_UIO_H */
*/
#ifndef _LIBSPL_UTSNAME_H
-#define _LIBSPL_UTSNAME_H
+#define _LIBSPL_UTSNAME_H
#include_next <sys/utsname.h>
*/
#ifndef _SYS_VA_LIST_H
-#define _SYS_VA_LIST_H
+#define _SYS_VA_LIST_H
#include <stdarg.h>
*/
#ifndef _LIBSPL_SYS_VARARGS_H
-#define _LIBSPL_SYS_VARARGS_H
+#define _LIBSPL_SYS_VARARGS_H
#endif
*/
#ifndef _LIBSPL_SYS_VNODE_H
-#define _LIBSPL_SYS_VNODE_H
+#define _LIBSPL_SYS_VNODE_H
#endif /* _LIBSPL_SYS_VNODE_H */
*/
#ifndef _LIBSPL_SYS_ZONE_H
-#define _LIBSPL_SYS_ZONE_H
+#define _LIBSPL_SYS_ZONE_H
#endif
*/
#ifndef _LIBSPL_THREAD_H
-#define _LIBSPL_THREAD_H
+#define _LIBSPL_THREAD_H
#endif /* _LIBSPL_THREAD_H */
*/
#ifndef _LIBSPL_TZFILE_H
-#define _LIBSPL_TZFILE_H
+#define _LIBSPL_TZFILE_H
#include <sys/tzfile.h>
*/
#ifndef _LIBSPL_UCRED_H
-#define _LIBSPL_UCRED_H
+#define _LIBSPL_UCRED_H
typedef int ucred_t;
*/
#ifndef _LIBSPL_UMEM_H
-#define _LIBSPL_UMEM_H
+#define _LIBSPL_UMEM_H
-/* XXX: We should use the real portable umem library if it is detected
+/*
+ * XXX: We should use the real portable umem library if it is detected
* at configure time. However, if the library is not available, we can
* use a trivial malloc based implementation. This obviously impacts
* performance, but unless you are using a full userspace build of zpool for
/*
* Flags for umem_alloc/umem_free
*/
-#define UMEM_DEFAULT 0x0000 /* normal -- may fail */
-#define UMEM_NOFAIL 0x0100 /* Never fails */
+#define UMEM_DEFAULT 0x0000 /* normal -- may fail */
+#define UMEM_NOFAIL 0x0100 /* Never fails */
/*
* Flags for umem_cache_create()
*/
-#define UMC_NOTOUCH 0x00010000
-#define UMC_NODEBUG 0x00020000
-#define UMC_NOMAGAZINE 0x00040000
-#define UMC_NOHASH 0x00080000
+#define UMC_NOTOUCH 0x00010000
+#define UMC_NODEBUG 0x00020000
+#define UMC_NOMAGAZINE 0x00040000
+#define UMC_NOHASH 0x00080000
-#define UMEM_CACHE_NAMELEN 31
+#define UMEM_CACHE_NAMELEN 31
typedef int umem_nofail_callback_t(void);
typedef int umem_constructor_t(void *, void *, int);
ptr = malloc(size);
} while (ptr == NULL && (flags & UMEM_NOFAIL));
- return ptr;
+ return (ptr);
}
static inline void *
__func__, align);
if (flags & UMEM_NOFAIL)
abort();
- return NULL;
+ return (NULL);
}
- return ptr;
+ return (ptr);
}
static inline void *
if (ptr)
memset(ptr, 0, size);
- return ptr;
+ return (ptr);
}
static inline void
umem_nofail_callback(umem_nofail_callback_t *cb) {}
static inline umem_cache_t *
-umem_cache_create(char *name, size_t bufsize, size_t align,
- umem_constructor_t *constructor,
- umem_destructor_t *destructor,
- umem_reclaim_t *reclaim,
- void *priv, void *vmp, int cflags)
+umem_cache_create(
+ char *name, size_t bufsize, size_t align,
+ umem_constructor_t *constructor,
+ umem_destructor_t *destructor,
+ umem_reclaim_t *reclaim,
+ void *priv, void *vmp, int cflags)
{
umem_cache_t *cp;
- cp = umem_alloc(sizeof(umem_cache_t), UMEM_DEFAULT);
+ cp = umem_alloc(sizeof (umem_cache_t), UMEM_DEFAULT);
if (cp) {
strncpy(cp->cache_name, name, UMEM_CACHE_NAMELEN);
cp->cache_bufsize = bufsize;
cp->cache_cflags = cflags;
}
- return cp;
+ return (cp);
}
static inline void
umem_cache_destroy(umem_cache_t *cp)
{
- umem_free(cp, sizeof(umem_cache_t));
+ umem_free(cp, sizeof (umem_cache_t));
}
static inline void *
void *ptr;
if (cp->cache_align != 0)
- ptr = umem_alloc_aligned(cp->cache_bufsize, cp->cache_align, flags);
+ ptr = umem_alloc_aligned(
+ cp->cache_bufsize, cp->cache_align, flags);
else
ptr = umem_alloc(cp->cache_bufsize, flags);
if (ptr && cp->cache_constructor)
cp->cache_constructor(ptr, cp->cache_private, UMEM_DEFAULT);
- return ptr;
+ return (ptr);
}
static inline void
#include_next <unistd.h>
#ifndef _LIBSPL_UNISTD_H
-#define _LIBSPL_UNISTD_H
+#define _LIBSPL_UNISTD_H
#if !defined(HAVE_IOCTL_IN_UNISTD_H)
-# if defined(HAVE_IOCTL_IN_SYS_IOCTL_H)
-# include <sys/ioctl.h>
-# elif defined(HAVE_IOCTL_IN_STROPTS_H)
-# include <stropts.h>
-# else
-# error "System call ioctl() unavailable"
-# endif
-#endif
+#if defined(HAVE_IOCTL_IN_SYS_IOCTL_H)
+#include <sys/ioctl.h>
+#elif defined(HAVE_IOCTL_IN_STROPTS_H)
+#include <stropts.h>
+#else /* HAVE_IOCTL_IN_STROPTS_H */
+#error "System call ioctl() unavailable"
+#endif /* HAVE_IOCTL_IN_SYS_IOCTL_H */
+#endif /* !HAVE_IOCTL_IN_UNISTD_H */
#if !defined(HAVE_ISSETUGID)
-# include <sys/types.h>
-# define issetugid() (geteuid() == 0 || getegid() == 0)
+#include <sys/types.h>
+#define issetugid() (geteuid() == 0 || getegid() == 0)
#endif
#endif /* _LIBSPL_UNISTD_H */
*/
#ifndef _LIBSPL_UTIL_SSCANF_H
-#define _LIBSPL_UTIL_SSCANF_H
+#define _LIBSPL_UTIL_SSCANF_H
#endif
extern "C" {
#endif
-#define GLOBAL_ZONEID 0
-#define GLOBAL_ZONEID_NAME "global"
+#define GLOBAL_ZONEID 0
+#define GLOBAL_ZONEID_NAME "global"
/*
* Functions for mapping between id and name for active zones.
#include <string.h>
#include <errno.h>
-zoneid_t getzoneid()
+zoneid_t
+getzoneid()
{
- return GLOBAL_ZONEID;
+ return (GLOBAL_ZONEID);
}
-zoneid_t getzoneidbyname(const char *name)
+zoneid_t
+getzoneidbyname(const char *name)
{
- if(name == NULL)
- return GLOBAL_ZONEID;
+ if (name == NULL)
+ return (GLOBAL_ZONEID);
- if(strcmp(name, GLOBAL_ZONEID_NAME) == 0)
- return GLOBAL_ZONEID;
+ if (strcmp(name, GLOBAL_ZONEID_NAME) == 0)
+ return (GLOBAL_ZONEID);
- return EINVAL;
+ return (EINVAL);
}
-ssize_t getzonenamebyid(zoneid_t id, char *buf, size_t buflen)
+ssize_t
+getzonenamebyid(zoneid_t id, char *buf, size_t buflen)
{
- if(id != GLOBAL_ZONEID)
- return EINVAL;
+ if (id != GLOBAL_ZONEID)
+ return (EINVAL);
ssize_t ret = strlen(GLOBAL_ZONEID_NAME) + 1;
- if(buf == NULL || buflen == 0)
- return ret;
+ if (buf == NULL || buflen == 0)
+ return (ret);
strncpy(buf, GLOBAL_ZONEID_NAME, buflen);
buf[buflen - 1] = '\0';
- return ret;
+ return (ret);
}
void
libzfs_fru_clear(libzfs_handle_t *hdl, boolean_t final)
{
- return;
}
#endif /* HAVE_LIBTOPO */
-
-
}
if ((strlen(path) == strlen(ne->ne_name)) &&
- !strncmp(path, ne->ne_name, strlen(path))) {
+ strncmp(path, ne->ne_name, strlen(path)) == 0) {
best = ne;
break;
}
err_blkid2:
blkid_put_cache(cache);
err_blkid1:
- return err;
+ return (err);
}
#endif /* HAVE_LIBBLKID */
* when access from Xen dom0.
*/
if ((strncmp(name, "watchdog", 8) == 0) ||
- (strncmp(name, "fuse", 4) == 0) ||
- (strncmp(name, "ppp", 3) == 0) ||
- (strncmp(name, "tty", 3) == 0) ||
- (strncmp(name, "vcs", 3) == 0) ||
- (strncmp(name, "parport", 7) == 0) ||
- (strncmp(name, "lp", 2) == 0) ||
- (strncmp(name, "fd", 2) == 0) ||
- (strncmp(name, "hpet", 4) == 0) ||
+ (strncmp(name, "fuse", 4) == 0) ||
+ (strncmp(name, "ppp", 3) == 0) ||
+ (strncmp(name, "tty", 3) == 0) ||
+ (strncmp(name, "vcs", 3) == 0) ||
+ (strncmp(name, "parport", 7) == 0) ||
+ (strncmp(name, "lp", 2) == 0) ||
+ (strncmp(name, "fd", 2) == 0) ||
+ (strncmp(name, "hpet", 4) == 0) ||
(strncmp(name, "core", 4) == 0))
continue;
ZPOOL_CONFIG_POOL_NAME, &pname) == 0)) {
if (strcmp(iarg->poolname, pname))
- matched = B_FALSE;
+ matched = B_FALSE;
} else if (iarg->guid != 0) {
uint64_t this_guid;
"-t", MNTTYPE_ZFS,
"-o", opts,
(char *)src,
- (char *)mntpt,
+ (char *)mntpt,
(char *)NULL };
int rc;
rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE);
if (rc) {
if (rc & MOUNT_FILEIO)
- return EIO;
+ return (EIO);
if (rc & MOUNT_USER)
- return EINTR;
+ return (EINTR);
if (rc & MOUNT_SOFTWARE)
- return EPIPE;
+ return (EPIPE);
if (rc & MOUNT_BUSY)
- return EBUSY;
+ return (EBUSY);
if (rc & MOUNT_SYSERR)
- return EAGAIN;
+ return (EAGAIN);
if (rc & MOUNT_USAGE)
- return EINVAL;
+ return (EINVAL);
- return ENXIO; /* Generic error */
+ return (ENXIO); /* Generic error */
}
- return 0;
+ return (0);
}
static int
mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp);
for (curr_proto = proto; *curr_proto != PROTO_END;
- curr_proto++) {
+ curr_proto++) {
if (is_shared(hdl, mntpt, *curr_proto) &&
unshare_one(hdl, zhp->zfs_name,
zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
zprop_source_t *srctype)
{
- return zpool_get_prop_literal(zhp, prop, buf, len, srctype, B_FALSE);
+ return (zpool_get_prop_literal(zhp, prop, buf, len, srctype, B_FALSE));
}
/*
* a pre-allocated buffer.
*/
int
-zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
- zprop_source_t *srctype, boolean_t literal)
+zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
+ size_t len, zprop_source_t *srctype, boolean_t literal)
{
uint64_t intval;
const char *strval;
* part of an active md or lvm device.
*/
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
- "one or more vdevs refer to the same device, or one of\n"
- "the devices is part of an active md or lvm device"));
+ "one or more vdevs refer to the same device, or "
+ "one of\nthe devices is part of an active md or "
+ "lvm device"));
return (zfs_error(hdl, EZFS_BADDEV, msg));
case EOVERFLOW:
if (path[0] != '/') {
error = zfs_resolve_shortname(path, buf,
- sizeof(buf));
+ sizeof (buf));
if (error != 0)
return (zfs_error(hdl, EZFS_NODEVICE,
msg));
libzfs_handle_t *hdl = zhp->zpool_hdl;
(void) snprintf(msg, sizeof (msg),
- dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);
+ dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_guid = guid;
libzfs_handle_t *hdl = zhp->zpool_hdl;
(void) snprintf(msg, sizeof (msg),
- dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
+ dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_guid = guid;
(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
- (u_longlong_t)guid);
+ (u_longlong_t)guid);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_guid = guid;
*/
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK,
&value) == 0 && value) {
- return strip_partition(hdl, path);
+ return (strip_partition(hdl, path));
}
} else {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);
if (dsobj == 0) {
/* special case for the MOS */
- (void) snprintf(pathname, len, "<metadata>:<0x%llx>", (longlong_t)obj);
+ (void) snprintf(pathname, len, "<metadata>:<0x%llx>",
+ (longlong_t)obj);
return;
}
dsname, zc.zc_value);
}
} else {
- (void) snprintf(pathname, len, "%s:<0x%llx>", dsname, (longlong_t)obj);
+ (void) snprintf(pathname, len, "%s:<0x%llx>", dsname,
+ (longlong_t)obj);
}
free(mntpnt);
}
int fd, err;
if ((fd = open(path, O_RDWR|O_DIRECT)) < 0)
- return errno;
+ return (errno);
if ((err = efi_alloc_and_read(fd, &vtoc)) != 0) {
(void) close(fd);
- return err;
+ return (err);
}
if (vtoc->efi_flags & EFI_GPT_PRIMARY_CORRUPT) {
efi_free(vtoc);
(void) close(fd);
- return EIDRM;
+ return (EIDRM);
}
efi_free(vtoc);
(void) close(fd);
- return 0;
+ return (0);
}
/*
return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
}
- return 0;
+ return (0);
}
const char path_prefix[] = "/sys/module/";
char path[256];
- memcpy(path, path_prefix, sizeof(path_prefix) - 1);
- strcpy(path + sizeof(path_prefix) - 1, module);
+ memcpy(path, path_prefix, sizeof (path_prefix) - 1);
+ strcpy(path + sizeof (path_prefix) - 1, module);
return (access(path, F_OK) == 0);
}
while ((rc = waitpid(pid, &status, 0)) == -1 &&
errno == EINTR);
if (rc < 0 || !WIFEXITED(status))
- return -1;
+ return (-1);
- return WEXITSTATUS(status);
+ return (WEXITSTATUS(status));
}
- return -1;
+ return (-1);
}
int
char *argv[4] = {"/sbin/modprobe", "-q", (char *)module, (char *)0};
if (libzfs_module_loaded(module))
- return 0;
+ return (0);
- return libzfs_run_process("/sbin/modprobe", argv, 0);
+ return (libzfs_run_process("/sbin/modprobe", argv, 0));
}
libzfs_handle_t *
if (libzfs_load_module("zfs") != 0) {
(void) fprintf(stderr, gettext("Failed to load ZFS module "
- "stack.\nLoad the module manually by running "
- "'insmod <location>/zfs.ko' as root.\n"));
+ "stack.\nLoad the module manually by running "
+ "'insmod <location>/zfs.ko' as root.\n"));
return (NULL);
}
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
(void) fprintf(stderr, gettext("Unable to open %s: %s.\n"),
- ZFS_DEV, strerror(errno));
+ ZFS_DEV, strerror(errno));
if (errno == ENOENT)
(void) fprintf(stderr,
- gettext("Verify the ZFS module stack is "
- "loaded by running '/sbin/modprobe zfs'.\n"));
+ gettext("Verify the ZFS module stack is "
+ "loaded by running '/sbin/modprobe zfs'.\n"));
free(hdl);
return (NULL);
if (wholedisk)
path_len = zfs_append_partition(path_name, MAXPATHLEN);
- if ((path_len == cmp_len) && !strcmp(path_name, cmp_name)) {
+ if ((path_len == cmp_len) && strcmp(path_name, cmp_name) == 0) {
error = 0;
break;
}
}
if (name[0] != '/')
- return zfs_strcmp_shortname(name, cmp_name, wholedisk);
+ return (zfs_strcmp_shortname(name, cmp_name, wholedisk));
strncpy(path_name, name, MAXPATHLEN);
path_len = strlen(path_name);
*/
if (buf[1] == '\0' ||
(toupper(buf[0]) != 'B' &&
- ((toupper(buf[1]) == 'B' && buf[2] == '\0') ||
- (toupper(buf[1]) == 'I' && toupper(buf[2]) == 'B' &&
- buf[3] == '\0'))))
- return (10*i);
+ ((toupper(buf[1]) == 'B' && buf[2] == '\0') ||
+ (toupper(buf[1]) == 'I' && toupper(buf[2]) == 'B' &&
+ buf[3] == '\0'))))
+ return (10 * i);
if (hdl)
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
VERIFY3S(pthread_key_create(&kthread_key, NULL), ==, 0);
/* Create entry for primary kthread */
- kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL);
+ kt = umem_zalloc(sizeof (kthread_t), UMEM_NOFAIL);
kt->t_tid = pthread_self();
kt->t_func = NULL;
ASSERT(pthread_equal(kt->t_tid, pthread_self()));
ASSERT3P(kt->t_func, ==, NULL);
- umem_free(kt, sizeof(kthread_t));
+ umem_free(kt, sizeof (kthread_t));
/* Wait for all threads to exit via thread_exit() */
VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0);
ASSERT3P(kt, !=, NULL);
- return kt;
+ return (kt);
}
void *
/* Unreachable, thread must exit with thread_exit() */
abort();
- return NULL;
+ return (NULL);
}
kthread_t *
zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg,
- size_t len, proc_t *pp, int state, pri_t pri, int detachstate)
+ size_t len, proc_t *pp, int state, pri_t pri, int detachstate)
{
kthread_t *kt;
pthread_attr_t attr;
ASSERT3S(state & ~TS_RUN, ==, 0);
- kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL);
+ kt = umem_zalloc(sizeof (kthread_t), UMEM_NOFAIL);
kt->t_func = func;
kt->t_arg = arg;
VERIFY3S(pthread_attr_destroy(&attr), ==, 0);
- return kt;
+ return (kt);
}
void
ASSERT(pthread_equal(kt->t_tid, pthread_self()));
- umem_free(kt, sizeof(kthread_t));
+ umem_free(kt, sizeof (kthread_t));
pthread_mutex_lock(&kthread_lock);
kthread_nr--;
* (memory or disk) due to O_DIRECT, so we abort() in order to
* catch the offender.
*/
- abort();
+ abort();
}
#endif
if (rc == -1)
int
taskq_empty_ent(taskq_ent_t *t)
{
- return t->tqent_next == NULL;
+ return (t->tqent_next == NULL);
}
void
tq->tq_maxalloc = maxalloc;
tq->tq_task.tqent_next = &tq->tq_task;
tq->tq_task.tqent_prev = &tq->tq_task;
- tq->tq_threadlist = kmem_alloc(nthreads*sizeof(kthread_t *), KM_SLEEP);
+ tq->tq_threadlist = kmem_alloc(nthreads * sizeof (kthread_t *),
+ KM_SLEEP);
if (flags & TASKQ_PREPOPULATE) {
mutex_enter(&tq->tq_lock);
{
nvpair_t *nvp;
const char *np;
- char *sepp=NULL;
+ char *sepp = NULL;
char *idxp, *idxep;
nvlist_t **nva;
long idx = 0;
}
const nv_alloc_ops_t spl_sleep_ops_def = {
- NULL, /* nv_ao_init() */
- NULL, /* nv_ao_fini() */
- nv_alloc_sleep_spl, /* nv_ao_alloc() */
- nv_free_spl, /* nv_ao_free() */
- NULL /* nv_ao_reset() */
+ NULL, /* nv_ao_init() */
+ NULL, /* nv_ao_fini() */
+ nv_alloc_sleep_spl, /* nv_ao_alloc() */
+ nv_free_spl, /* nv_ao_free() */
+ NULL /* nv_ao_reset() */
};
const nv_alloc_ops_t spl_pushpage_ops_def = {
- NULL, /* nv_ao_init() */
- NULL, /* nv_ao_fini() */
- nv_alloc_pushpage_spl, /* nv_ao_alloc() */
- nv_free_spl, /* nv_ao_free() */
- NULL /* nv_ao_reset() */
+ NULL, /* nv_ao_init() */
+ NULL, /* nv_ao_fini() */
+ nv_alloc_pushpage_spl, /* nv_ao_alloc() */
+ nv_free_spl, /* nv_ao_free() */
+ NULL /* nv_ao_reset() */
};
const nv_alloc_ops_t spl_nosleep_ops_def = {
- NULL, /* nv_ao_init() */
- NULL, /* nv_ao_fini() */
- nv_alloc_nosleep_spl, /* nv_ao_alloc() */
- nv_free_spl, /* nv_ao_free() */
- NULL /* nv_ao_reset() */
+ NULL, /* nv_ao_init() */
+ NULL, /* nv_ao_fini() */
+ nv_alloc_nosleep_spl, /* nv_ao_alloc() */
+ nv_free_spl, /* nv_ao_free() */
+ NULL /* nv_ao_reset() */
};
nv_alloc_t nv_alloc_sleep_def = {
/* The following are some convenience macros. */
#define U8_PUT_3BYTES_INTO_UTF32(u, b1, b2, b3) \
(u) = ((((uint32_t)(b1) & 0x0F) << 12) | \
- (((uint32_t)(b2) & 0x3F) << 6) | \
+ (((uint32_t)(b2) & 0x3F) << 6) | \
((uint32_t)(b3) & 0x3F));
#define U8_SIMPLE_SWAP(a, b, t) \
switch (uio->uio_segflg) {
case UIO_USERSPACE:
case UIO_USERISPACE:
- /* p = kernel data pointer
- * iov->iov_base = user data pointer */
-
+ /*
+ * p = kernel data pointer
+ * iov->iov_base = user data pointer
+ */
if (rw == UIO_READ) {
if (copy_to_user(iov->iov_base, p, cnt))
- return EFAULT;
- /* error = xcopyout_nta(p, iov->iov_base, cnt,
- * (uio->uio_extflg & UIO_COPY_CACHED)); */
+ return (EFAULT);
} else {
- /* error = xcopyin_nta(iov->iov_base, p, cnt,
- * (uio->uio_extflg & UIO_COPY_CACHED)); */
if (copy_from_user(p, iov->iov_base, cnt))
- return EFAULT;
+ return (EFAULT);
}
break;
case UIO_SYSSPACE:
}
EXPORT_SYMBOL(uiomove);
-#define fuword8(uptr, vptr) get_user((*vptr), (uptr))
+#define fuword8(uptr, vptr) get_user((*vptr), (uptr))
/*
* Fault in the pages of the first n bytes specified by the uio structure.
case UIO_USERSPACE:
case UIO_USERISPACE:
- /* p = kernel data pointer
- * iov->iov_base = user data pointer */
-
+ /*
+ * p = kernel data pointer
+ * iov->iov_base = user data pointer
+ */
if (rw == UIO_READ) {
- /* * UIO_READ = copy data from kernel to user * */
+ /* UIO_READ = copy data from kernel to user */
if (copy_to_user(iov->iov_base, p, cnt))
- return EFAULT;
- /* error = xcopyout_nta(p, iov->iov_base, cnt,
- * (uio->uio_extflg & UIO_COPY_CACHED)); */
+ return (EFAULT);
} else {
- /* * UIO_WRITE = copy data from user to kernel * */
- /* error = xcopyin_nta(iov->iov_base, p, cnt,
- * (uio->uio_extflg & UIO_COPY_CACHED)); */
+ /* UIO_WRITE = copy data from user to kernel */
if (copy_from_user(p, iov->iov_base, cnt))
- return EFAULT;
+ return (EFAULT);
}
break;
int i;
#if defined(_KERNEL) && defined(HAVE_SPL)
- /* Large allocations which do not require contiguous pages
- * should be using vmem_free() in the linux kernel */
+ /*
+ * Large allocations which do not require contiguous pages
+ * should be using vmem_free() in the linux kernel\
+ */
vmem_free(buf_hash_table.ht_table,
(buf_hash_table.ht_mask + 1) * sizeof (void *));
#else
retry:
buf_hash_table.ht_mask = hsize - 1;
#if defined(_KERNEL) && defined(HAVE_SPL)
- /* Large allocations which do not require contiguous pages
- * should be using vmem_alloc() in the linux kernel */
+ /*
+ * Large allocations which do not require contiguous pages
+ * should be using vmem_alloc() in the linux kernel
+ */
buf_hash_table.ht_table =
vmem_zalloc(hsize * sizeof (void*), KM_SLEEP);
#else
return;
}
buf->b_hdr->b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t),
- KM_PUSHPAGE);
+ KM_PUSHPAGE);
fletcher_2_native(buf->b_data, buf->b_hdr->b_size,
buf->b_hdr->b_freeze_cksum);
mutex_exit(&buf->b_hdr->b_freeze_lock);
arc_buf_hdr_t *hdr = ab->b_hdr;
arc_state_t *state = hdr->b_state;
- memset(abi, 0, sizeof(arc_buf_info_t));
+ memset(abi, 0, sizeof (arc_buf_info_t));
abi->abi_flags = hdr->b_flags;
abi->abi_datacnt = hdr->b_datacnt;
abi->abi_state_type = state ? state->arcs_state : ARC_STATE_ANON;
int count = 0;
ASSERT(GHOST_STATE(state));
- bzero(&marker, sizeof(marker));
+ bzero(&marker, sizeof (marker));
top:
mutex_enter(&state->arcs_mtx);
for (ab = list_tail(list); ab; ab = ab_prev) {
}
/* reset the growth delay for every reclaim */
- arc_grow_time = ddi_get_lbolt()+(zfs_arc_grow_retry * hz);
+ arc_grow_time = ddi_get_lbolt() +
+ (zfs_arc_grow_retry * hz);
arc_kmem_reap_now(last_reclaim, 0);
arc_warm = B_TRUE;
{
arc_prune_t *p;
- p = kmem_alloc(sizeof(*p), KM_SLEEP);
+ p = kmem_alloc(sizeof (*p), KM_SLEEP);
p->p_pfunc = func;
p->p_private = private;
list_link_init(&p->p_node);
list_insert_head(dev->l2ad_buflist, head);
cb = kmem_alloc(sizeof (l2arc_write_callback_t),
- KM_PUSHPAGE);
+ KM_PUSHPAGE);
cb->l2wcb_dev = dev;
cb->l2wcb_head = head;
pio = zio_root(spa, l2arc_write_done, cb,
retry:
h->hash_table_mask = hsize - 1;
#if defined(_KERNEL) && defined(HAVE_SPL)
- /* Large allocations which do not require contiguous pages
- * should be using vmem_alloc() in the linux kernel */
+ /*
+ * Large allocations which do not require contiguous pages
+ * should be using vmem_alloc() in the linux kernel
+ */
h->hash_table = vmem_zalloc(hsize * sizeof (void *), KM_PUSHPAGE);
#else
h->hash_table = kmem_zalloc(hsize * sizeof (void *), KM_NOSLEEP);
for (i = 0; i < DBUF_MUTEXES; i++)
mutex_destroy(&h->hash_mutexes[i]);
#if defined(_KERNEL) && defined(HAVE_SPL)
- /* Large allocations which do not require contiguous pages
- * should be using vmem_free() in the linux kernel */
+ /*
+ * Large allocations which do not require contiguous pages
+ * should be using vmem_free() in the linux kernel
+ */
vmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *));
#else
kmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *));
if (dh == NULL) {
err = dbuf_hold_impl(dn, level+1, blkid >> epbs,
fail_sparse, NULL, parentp);
- }
- else {
+ } else {
__dbuf_hold_impl_init(dh + 1, dn, dh->dh_level + 1,
blkid >> epbs, fail_sparse, NULL,
parentp, dh->dh_depth + 1);
}
}
-#define DBUF_HOLD_IMPL_MAX_DEPTH 20
+#define DBUF_HOLD_IMPL_MAX_DEPTH 20
/*
* Returns with db_holds incremented, and db_mtx not held.
dh->dh_fail_sparse, &dh->dh_parent,
&dh->dh_bp, dh);
if (dh->dh_fail_sparse) {
- if (dh->dh_err == 0 && dh->dh_bp && BP_IS_HOLE(dh->dh_bp))
+ if (dh->dh_err == 0 &&
+ dh->dh_bp && BP_IS_HOLE(dh->dh_bp))
dh->dh_err = SET_ERROR(ENOENT);
if (dh->dh_err) {
if (dh->dh_parent)
struct dbuf_hold_impl_data *dh;
int error;
- dh = kmem_zalloc(sizeof(struct dbuf_hold_impl_data) *
+ dh = kmem_zalloc(sizeof (struct dbuf_hold_impl_data) *
DBUF_HOLD_IMPL_MAX_DEPTH, KM_PUSHPAGE);
__dbuf_hold_impl_init(dh, dn, level, blkid, fail_sparse, tag, dbp, 0);
error = __dbuf_hold_impl(dh);
- kmem_free(dh, sizeof(struct dbuf_hold_impl_data) *
+ kmem_free(dh, sizeof (struct dbuf_hold_impl_data) *
DBUF_HOLD_IMPL_MAX_DEPTH);
return (error);
}
}
-/* dbuf_sync_indirect() is called recursively from dbuf_sync_list() so it
+/*
+ * dbuf_sync_indirect() is called recursively from dbuf_sync_list() so it
* is critical the we not allow the compiler to inline this function in to
* dbuf_sync_list() thereby drastically bloating the stack usage.
*/
zio_nowait(zio);
}
-/* dbuf_sync_leaf() is called recursively from dbuf_sync_list() so it is
+/*
+ * dbuf_sync_leaf() is called recursively from dbuf_sync_list() so it is
* critical the we not allow the compiler to inline this function in to
* dbuf_sync_list() thereby drastically bloating the stack usage.
*/
"%-6s %-6s %-8s %-8s %-6s %-6s %-5s %-8s %-8s\n",
"dbuf", "arcbuf", "dnode", "pool", "objset", "object", "level",
"blkid", "offset", "dbsize", "meta", "state", "dbholds", "list",
- "atype", "index", "flags", "count", "asize", "access", "mru", "gmru",
- "mfu", "gmfu", "l2", "l2_dattr", "l2_asize", "l2_comp", "aholds",
- "dtype", "btype", "data_bs", "meta_bs", "bsize",
- "lvls", "dholds", "blocks", "dsize");
- buf[size] = '\0';
+ "atype", "index", "flags", "count", "asize", "access",
+ "mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr", "l2_asize",
+ "l2_comp", "aholds", "dtype", "btype", "data_bs", "meta_bs",
+ "bsize", "lvls", "dholds", "blocks", "dsize");
+ buf[size] = '\0';
return (0);
}
(ulong_t)refcount_count(&dn->dn_holds),
(u_longlong_t)doi.doi_fill_count,
(u_longlong_t)doi.doi_max_offset);
- buf[size] = '\0';
+ buf[size] = '\0';
return (size);
}
{
dbuf_stats_t *dsh = ksp->ks_private;
- ASSERT(MUTEX_HELD(&dsh->lock));
+ ASSERT(MUTEX_HELD(&dsh->lock));
if (n <= dsh->hash->hash_table_mask) {
dsh->idx = n;
return (B_TRUE);
ddt = spa->spa_ddt[BP_GET_CHECKSUM(bp)];
- dde = kmem_alloc(sizeof(ddt_entry_t), KM_PUSHPAGE);
+ dde = kmem_alloc(sizeof (ddt_entry_t), KM_PUSHPAGE);
ddt_key_fill(&(dde->dde_key), bp);
for (type = 0; type < DDT_TYPES; type++) {
for (class = 0; class <= max_class; class++) {
if (ddt_object_lookup(ddt, type, class, dde) == 0) {
- kmem_free(dde, sizeof(ddt_entry_t));
+ kmem_free(dde, sizeof (ddt_entry_t));
return (B_TRUE);
}
}
}
- kmem_free(dde, sizeof(ddt_entry_t));
+ kmem_free(dde, sizeof (ddt_entry_t));
return (B_FALSE);
}
#if defined(_KERNEL) && defined(HAVE_SPL)
module_param(zfs_dedup_prefetch, int, 0644);
-MODULE_PARM_DESC(zfs_dedup_prefetch,"Enable prefetching dedup-ed blks");
+MODULE_PARM_DESC(zfs_dedup_prefetch, "Enable prefetching dedup-ed blks");
#endif
static int
ddt_zap_count(objset_t *os, uint64_t object, uint64_t *count)
{
- return zap_count(os, object, count);
+ return (zap_count(os, object, count));
}
const ddt_ops_t ddt_zap_ops = {
}
nblks = 1;
}
- dbp = kmem_zalloc(sizeof (dmu_buf_t *) * nblks, KM_PUSHPAGE | KM_NODEBUG);
+ dbp = kmem_zalloc(sizeof (dmu_buf_t *) * nblks,
+ KM_PUSHPAGE | KM_NODEBUG);
zio = zio_root(dn->dn_objset->os_spa, NULL, NULL, ZIO_FLAG_CANFAIL);
blkid = dbuf_whichblock(dn, offset);
{ "write_buf_nocopy", KSTAT_DATA_UINT64 }
};
-#define XUIOSTAT_INCR(stat, val) \
- atomic_add_64(&xuio_stats.stat.value.ui64, (val))
-#define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1)
+#define XUIOSTAT_INCR(stat, val) \
+ atomic_add_64(&xuio_stats.stat.value.ui64, (val))
+#define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1)
int
dmu_xuio_init(xuio_t *xuio, int nblk)
bv->bv_len -= tocpy;
}
- return 0;
+ return (0);
}
static void
struct bio *bio_new;
if (bio == NULL)
- return EINVAL;
+ return (EINVAL);
while (bio) {
bio_new = bio_clone(bio, GFP_NOIO);
if (bio_new == NULL) {
dmu_bio_put(bio_root);
- return ENOMEM;
+ return (ENOMEM);
}
if (bio_last) {
*bio_copy = bio_root;
- return 0;
+ return (0);
}
int
* to be reading in parallel.
*/
err = dmu_buf_hold_array(os, object, offset, size, TRUE, FTAG,
- &numbufs, &dbp);
+ &numbufs, &dbp);
if (err)
return (err);
return (0);
err = dmu_buf_hold_array(os, object, offset, size, FALSE, FTAG,
- &numbufs, &dbp);
+ &numbufs, &dbp);
if (err)
return (err);
zio_nowait(zio_write(pio, os->os_spa, dmu_tx_get_txg(tx), zgd->zgd_bp,
zgd->zgd_db->db_data, zgd->zgd_db->db_size, zp,
dmu_sync_late_arrival_ready, NULL, dmu_sync_late_arrival_done, dsa,
- ZIO_PRIORITY_SYNC_WRITE, ZIO_FLAG_CANFAIL | ZIO_FLAG_FASTWRITE, zb));
+ ZIO_PRIORITY_SYNC_WRITE, ZIO_FLAG_CANFAIL|ZIO_FLAG_FASTWRITE, zb));
return (0);
}
int
dmu_snapshot_lookup(objset_t *os, const char *name, uint64_t *value)
{
- return dsl_dataset_snap_lookup(os->os_dsl_dataset, name, value);
+ return (dsl_dataset_snap_lookup(os->os_dsl_dataset, name, value));
}
int
if (cur_streams >= max_streams) {
return;
}
- newstream = kmem_zalloc(sizeof (zstream_t), KM_PUSHPAGE);
+ newstream =
+ kmem_zalloc(sizeof (zstream_t), KM_PUSHPAGE);
}
newstream->zst_offset = zst.zst_offset;
module_param(zfetch_array_rd_sz, ulong, 0644);
MODULE_PARM_DESC(zfetch_array_rd_sz, "Number of bytes in a array_read");
#endif
-
#ifdef _KERNEL
if (error == 0) {
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
- pair = nvlist_next_nvpair(snaps, pair)) {
+ pair = nvlist_next_nvpair(snaps, pair)) {
char *snapname = nvpair_name(pair);
zvol_create_minors(snapname);
}
dp = startdd->dd_pool;
mos = dp->dp_meta_objset;
- zc = kmem_alloc(sizeof(zap_cursor_t), KM_SLEEP);
- za = kmem_alloc(sizeof(zap_attribute_t), KM_SLEEP);
- basezc = kmem_alloc(sizeof(zap_cursor_t), KM_SLEEP);
- baseza = kmem_alloc(sizeof(zap_attribute_t), KM_SLEEP);
+ zc = kmem_alloc(sizeof (zap_cursor_t), KM_SLEEP);
+ za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
+ basezc = kmem_alloc(sizeof (zap_cursor_t), KM_SLEEP);
+ baseza = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
source = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, KM_SLEEP);
VERIFY(nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_SLEEP) == 0);
}
kmem_free(source, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1);
- kmem_free(baseza, sizeof(zap_attribute_t));
- kmem_free(basezc, sizeof(zap_cursor_t));
- kmem_free(za, sizeof(zap_attribute_t));
- kmem_free(zc, sizeof(zap_cursor_t));
+ kmem_free(baseza, sizeof (zap_attribute_t));
+ kmem_free(basezc, sizeof (zap_cursor_t));
+ kmem_free(za, sizeof (zap_attribute_t));
+ kmem_free(zc, sizeof (zap_cursor_t));
dsl_dir_rele(startdd, FTAG);
dsl_pool_rele(dp, FTAG);
return (0);
dsda.dsda_snaps = snaps;
- VERIFY0(nvlist_alloc(&dsda.dsda_successful_snaps, NV_UNIQUE_NAME, KM_PUSHPAGE));
+ VERIFY0(nvlist_alloc(&dsda.dsda_successful_snaps,
+ NV_UNIQUE_NAME, KM_PUSHPAGE));
dsda.dsda_defer = defer;
dsda.dsda_errlist = errlist;
nvlist_t *nvl;
nvlist_t *errlist;
- VERIFY0(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_PUSHPAGE));
- VERIFY0(nvlist_alloc(&errlist, NV_UNIQUE_NAME, KM_PUSHPAGE));
+ VERIFY0(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_PUSHPAGE));
+ VERIFY0(nvlist_alloc(&errlist, NV_UNIQUE_NAME, KM_PUSHPAGE));
fnvlist_add_boolean(nvl, name);
error = dsl_destroy_snapshots_nvl(nvl, defer, errlist);
dsl_dir_evict(dmu_buf_t *db, void *arg)
{
dsl_dir_t *dd = arg;
- ASSERTV(dsl_pool_t *dp = dd->dd_pool;)
int t;
+ ASSERTV(dsl_pool_t *dp = dd->dd_pool);
for (t = 0; t < TXG_SIZE; t++) {
ASSERT(!txg_list_member(&dp->dp_dirty_dirs, dd, t));
zfs_prop_to_name(ZFS_PROP_RESERVATION),
ddsqra->ddsqra_source, sizeof (ddsqra->ddsqra_value), 1,
&ddsqra->ddsqra_value, tx);
-
+
VERIFY0(dsl_prop_get_int_ds(ds,
zfs_prop_to_name(ZFS_PROP_RESERVATION), &newval));
} else {
dsl_dir_set_reservation_sync_impl(ds->ds_dir, newval, tx);
dsl_dataset_rele(ds, FTAG);
- }
+}
int
dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
EXPORT_SYMBOL(dsl_pool_config_enter);
EXPORT_SYMBOL(dsl_pool_config_exit);
-/* zfs_dirty_data_max_percent only applied at module load time in arc_init(). */
+/* zfs_dirty_data_max_percent only applied at module load in arc_init(). */
module_param(zfs_dirty_data_max_percent, int, 0444);
MODULE_PARM_DESC(zfs_dirty_data_max_percent, "percent of ram can be dirty");
-/* zfs_dirty_data_max_max_percent only applied at module load time in
- * arc_init(). */
+/* zfs_dirty_data_max_max_percent only applied at module load in arc_init(). */
module_param(zfs_dirty_data_max_max_percent, int, 0444);
MODULE_PARM_DESC(zfs_dirty_data_max_max_percent,
- "zfs_dirty_data_max upper bound as % of RAM");
+ "zfs_dirty_data_max upper bound as % of RAM");
module_param(zfs_delay_min_dirty_percent, int, 0644);
MODULE_PARM_DESC(zfs_delay_min_dirty_percent, "transaction delay threshold");
module_param(zfs_dirty_data_max, ulong, 0644);
MODULE_PARM_DESC(zfs_dirty_data_max, "determines the dirty space limit");
-/* zfs_dirty_data_max_max only applied at module load time in arc_init(). */
+/* zfs_dirty_data_max_max only applied at module load in arc_init(). */
module_param(zfs_dirty_data_max_max, ulong, 0444);
MODULE_PARM_DESC(zfs_dirty_data_max_max,
- "zfs_dirty_data_max upper bound in bytes");
+ "zfs_dirty_data_max upper bound in bytes");
module_param(zfs_dirty_data_sync, ulong, 0644);
MODULE_PARM_DESC(zfs_dirty_data_sync, "sync txg when this much dirty data");
if (vdev_resilver_needed(spa->spa_root_vdev,
&scn->scn_phys.scn_min_txg, &scn->scn_phys.scn_max_txg)) {
- spa_event_notify(spa, NULL, FM_EREPORT_ZFS_RESILVER_START);
+ spa_event_notify(spa, NULL,
+ FM_EREPORT_ZFS_RESILVER_START);
} else {
- spa_event_notify(spa, NULL, FM_EREPORT_ZFS_SCRUB_START);
+ spa_event_notify(spa, NULL,
+ FM_EREPORT_ZFS_SCRUB_START);
}
spa->spa_scrub_started = B_TRUE;
if (buf)
(void) arc_buf_remove_ref(buf, &buf);
out:
- kmem_free(bp_toread, sizeof(blkptr_t));
+ kmem_free(bp_toread, sizeof (blkptr_t));
}
static void
* bookmark so we don't think that we're still trying to resume.
*/
bzero(&scn->scn_phys.scn_bookmark, sizeof (zbookmark_t));
- zc = kmem_alloc(sizeof(zap_cursor_t), KM_PUSHPAGE);
- za = kmem_alloc(sizeof(zap_attribute_t), KM_PUSHPAGE);
+ zc = kmem_alloc(sizeof (zap_cursor_t), KM_PUSHPAGE);
+ za = kmem_alloc(sizeof (zap_attribute_t), KM_PUSHPAGE);
/* keep pulling things out of the zap-object-as-queue */
while (zap_cursor_init(zc, dp->dp_meta_objset,
}
zap_cursor_fini(zc);
out:
- kmem_free(za, sizeof(zap_attribute_t));
- kmem_free(zc, sizeof(zap_cursor_t));
+ kmem_free(za, sizeof (zap_attribute_t));
+ kmem_free(zc, sizeof (zap_cursor_t));
}
static boolean_t
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_int8_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_uint8_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_int16_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_uint16_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_int32_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_uint32_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_int64_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
c = fm_printf(d + 1, c, cols, "[ ");
(void) nvpair_value_uint64_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++)
- c = fm_printf(d + 1, c, cols, "0x%llx ",
- (u_longlong_t)val[i]);
+ c = fm_printf(d + 1, c, cols, "0x%llx ",
+ (u_longlong_t)val[i]);
c = fm_printf(d + 1, c, cols, "]");
break;
{
zevent_t *ev;
- ev = kmem_zalloc(sizeof(zevent_t), KM_PUSHPAGE);
+ ev = kmem_zalloc(sizeof (zevent_t), KM_PUSHPAGE);
if (ev == NULL)
- return NULL;
+ return (NULL);
- list_create(&ev->ev_ze_list, sizeof(zfs_zevent_t),
+ list_create(&ev->ev_ze_list, sizeof (zfs_zevent_t),
offsetof(zfs_zevent_t, ze_node));
list_link_init(&ev->ev_node);
- return ev;
+ return (ev);
}
static void
ev->ev_cb(ev->ev_nvl, ev->ev_detector);
list_destroy(&ev->ev_ze_list);
- kmem_free(ev, sizeof(zevent_t));
+ kmem_free(ev, sizeof (zevent_t));
}
static void
return;
}
- ev->ev_nvl = nvl;
+ ev->ev_nvl = nvl;
ev->ev_detector = detector;
ev->ev_cb = cb;
file_t *fp;
int error;
- fp = getf(fd);
- if (fp == NULL)
- return (EBADF);
+ fp = getf(fd);
+ if (fp == NULL)
+ return (EBADF);
- *minorp = zfsdev_getminor(fp->f_file);
- error = zfs_zevent_minor_to_state(*minorp, ze);
+ *minorp = zfsdev_getminor(fp->f_file);
+ error = zfs_zevent_minor_to_state(*minorp, ze);
if (error)
zfs_zevent_fd_rele(fd);
*/
int
zfs_zevent_next(zfs_zevent_t *ze, nvlist_t **event, uint64_t *event_size,
- uint64_t *dropped)
+ uint64_t *dropped)
{
zevent_t *ev;
size_t size;
goto out;
}
} else {
- /* Existing stream continue with the next element and remove
- * ourselves from the wait queue for the previous element */
+ /*
+ * Existing stream continue with the next element and remove
+ * ourselves from the wait queue for the previous element
+ */
ev = list_prev(&zevent_list, ze->ze_zevent);
if (ev == NULL) {
error = ENOENT;
out:
mutex_exit(&zevent_lock);
- return error;
+ return (error);
}
int
out:
mutex_exit(&zevent_lock);
- return error;
+ return (error);
}
void
}
mutex_init(&zevent_lock, NULL, MUTEX_DEFAULT, NULL);
- list_create(&zevent_list, sizeof(zevent_t), offsetof(zevent_t, ev_node));
+ list_create(&zevent_list, sizeof (zevent_t),
+ offsetof(zevent_t, ev_node));
cv_init(&zevent_cv, NULL, CV_DEFAULT, NULL);
}
#include <sys/zmod.h>
typedef size_t zlen_t;
-#define compress_func z_compress_level
-#define uncompress_func z_uncompress
+#define compress_func z_compress_level
+#define uncompress_func z_uncompress
#else /* _KERNEL */
#include <zlib.h>
typedef uLongf zlen_t;
-#define compress_func compress2
-#define uncompress_func uncompress
+#define compress_func compress2
+#define uncompress_func uncompress
#endif
/*ARGSUSED*/
size_t
-lz4_compress_zfs(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
+lz4_compress_zfs(void *s_start, void *d_start, size_t s_len,
+ size_t d_len, int n)
{
uint32_t bufsiz;
char *dest = d_start;
/*ARGSUSED*/
int
-lz4_decompress_zfs(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
+lz4_decompress_zfs(void *s_start, void *d_start, size_t s_len,
+ size_t d_len, int n)
{
const char *src = s_start;
uint32_t bufsiz = BE_IN32(src);
* This function explicitly handles the CTX memory structure.
*
* ILLUMOS CHANGES: the CTX memory structure must be explicitly allocated
- * by the caller (either on the stack or using kmem_cache_alloc). Passing NULL
- * isn't valid.
+ * by the caller (either on the stack or using kmem_cache_alloc). Passing
+ * NULL isn't valid.
*
* LZ4_compress64kCtx() :
* Same as LZ4_compressCtx(), but specific to small inputs (<64KB).
* isize *Must* be <64KB, otherwise the output will be corrupted.
*
* ILLUMOS CHANGES: the CTX memory structure must be explicitly allocated
- * by the caller (either on the stack or using kmem_cache_alloc). Passing NULL
- * isn't valid.
+ * by the caller (either on the stack or using kmem_cache_alloc). Passing
+ * NULL isn't valid.
*/
/*
#define unlikely(expr) expect((expr) != 0, 0)
#endif
-#define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | \
+#define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | \
(((x) & 0xffu) << 8)))
/* Basic types */
lz4_cache = NULL;
}
}
-
while (src < (uchar_t *)s_start + s_len) {
if ((copymask <<= 1) == (1 << NBBY)) {
if (dst >= (uchar_t *)d_start + d_len - 1 - 2 * NBBY) {
- kmem_free(lempel, LEMPEL_SIZE*sizeof(uint16_t));
+ kmem_free(lempel,
+ LEMPEL_SIZE*sizeof (uint16_t));
return (s_len);
}
copymask = 1;
#include <sys/vdev_impl.h>
#include <sys/zio.h>
-#define WITH_DF_BLOCK_ALLOCATOR
+#define WITH_DF_BLOCK_ALLOCATOR
/*
* Allow allocations to switch to gang blocks quickly. We do this to
return (error);
}
-void metaslab_fastwrite_mark(spa_t *spa, const blkptr_t *bp)
+void
+metaslab_fastwrite_mark(spa_t *spa, const blkptr_t *bp)
{
const dva_t *dva = bp->blk_dva;
int ndvas = BP_GET_NDVAS(bp);
spa_config_exit(spa, SCL_VDEV, FTAG);
}
-void metaslab_fastwrite_unmark(spa_t *spa, const blkptr_t *bp)
+void
+metaslab_fastwrite_unmark(spa_t *spa, const blkptr_t *bp)
{
const dva_t *dva = bp->blk_dva;
int ndvas = BP_GET_NDVAS(bp);
void *
sa_spill_alloc(int flags)
{
- return kmem_cache_alloc(spill_cache, flags);
+ return (kmem_cache_alloc(spill_cache, flags));
}
void
}
if (is_var_sz && var_size > 1) {
- /* Don't worry that the spill block might overflow.
+ /*
+ * Don't worry that the spill block might overflow.
* It will be resized if needed in sa_build_layouts().
*/
if (buftype == SA_SPILL ||
sa_free_attr_table(sa);
cookie = NULL;
- while ((layout = avl_destroy_nodes(&sa->sa_layout_hash_tree, &cookie))){
+ while ((layout =
+ avl_destroy_nodes(&sa->sa_layout_hash_tree, &cookie))) {
sa_idx_tab_t *tab;
while ((tab = list_head(&layout->lot_idx_tab))) {
ASSERT(refcount_count(&tab->sa_refcount));
}
cookie = NULL;
- while ((layout = avl_destroy_nodes(&sa->sa_layout_num_tree, &cookie))){
+ while ((layout = avl_destroy_nodes(&sa->sa_layout_num_tree, &cookie))) {
kmem_free(layout->lot_attrs,
sizeof (sa_attr_type_t) * layout->lot_attr_count);
kmem_free(layout, sizeof (sa_lot_t));
err = nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_PUSHPAGE);
if (err)
- return err;
+ return (err);
mutex_enter(&spa->spa_props_lock);
break;
}
- if ((error = dmu_objset_hold(strval,FTAG,&os)))
+ error = dmu_objset_hold(strval, FTAG, &os);
+ if (error)
break;
/* Must be ZPL and not gzip compressed. */
hostid != myhostid) {
nvlist_free(nvconfig);
cmn_err(CE_WARN, "pool '%s' could not be "
- "loaded as it was last accessed by "
- "another system (host: %s hostid: 0x%lx). "
- "See: http://zfsonlinux.org/msg/ZFS-8000-EY",
+ "loaded as it was last accessed by another "
+ "system (host: %s hostid: 0x%lx). See: "
+ "http://zfsonlinux.org/msg/ZFS-8000-EY",
spa_name(spa), hostname,
(unsigned long)hostid);
return (SET_ERROR(EBADF));
if (dsl_dsobj_to_dsname(spa_name(spa),
spa->spa_bootfs, tmpname) == 0) {
char *cp;
- char *dsname = kmem_alloc(MAXPATHLEN, KM_PUSHPAGE);
+ char *dsname;
+
+ dsname = kmem_alloc(MAXPATHLEN, KM_PUSHPAGE);
cp = strchr(tmpname, '/');
if (cp == NULL) {
if (sav->sav_count == 0) {
VERIFY(nvlist_add_nvlist_array(nvroot, config, NULL, 0) == 0);
} else {
- list = kmem_alloc(sav->sav_count * sizeof (void *), KM_PUSHPAGE);
+ list = kmem_alloc(sav->sav_count*sizeof (void *), KM_PUSHPAGE);
for (i = 0; i < sav->sav_count; i++)
list[i] = vdev_config_generate(spa, sav->sav_vdevs[i],
B_FALSE, VDEV_CONFIG_L2CACHE);
int err;
nvlist_t *nvl;
- VERIFY0(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_PUSHPAGE));
+ VERIFY0(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_PUSHPAGE));
fnvlist_add_string(nvl, ZPOOL_HIST_CMD, msg);
err = spa_history_log_nvl(spa, nvl);
EXPORT_SYMBOL(spa_namespace_lock);
module_param(zfs_deadman_synctime_ms, ulong, 0644);
-MODULE_PARM_DESC(zfs_deadman_synctime_ms,"Expiration time in milliseconds");
+MODULE_PARM_DESC(zfs_deadman_synctime_ms, "Expiration time in milliseconds");
module_param(zfs_deadman_enabled, int, 0644);
MODULE_PARM_DESC(zfs_deadman_enabled, "Enable deadman timer");
module_param(spa_asize_inflation, int, 0644);
MODULE_PARM_DESC(spa_asize_inflation,
- "SPA size estimate multiplication factor");
+ "SPA size estimate multiplication factor");
#endif
while ((srh = list_remove_head(&ssh->list))) {
ssh->size--;
- kmem_free(srh, sizeof(spa_read_history_t));
+ kmem_free(srh, sizeof (spa_read_history_t));
}
ASSERT3U(ssh->size, ==, 0);
}
ksp->ks_ndata = ssh->size;
- ksp->ks_data_size = ssh->size * sizeof(spa_read_history_t);
+ ksp->ks_data_size = ssh->size * sizeof (spa_read_history_t);
return (0);
}
mutex_enter(&ssh->lock);
while ((srh = list_remove_head(&ssh->list))) {
ssh->size--;
- kmem_free(srh, sizeof(spa_read_history_t));
+ kmem_free(srh, sizeof (spa_read_history_t));
}
ASSERT3U(ssh->size, ==, 0);
if (zfs_read_history_hits == 0 && (aflags & ARC_CACHED))
return;
- srh = kmem_zalloc(sizeof(spa_read_history_t), KM_PUSHPAGE);
- strlcpy(srh->origin, zb->zb_func, sizeof(srh->origin));
- strlcpy(srh->comm, getcomm(), sizeof(srh->comm));
+ srh = kmem_zalloc(sizeof (spa_read_history_t), KM_PUSHPAGE);
+ strlcpy(srh->origin, zb->zb_func, sizeof (srh->origin));
+ strlcpy(srh->comm, getcomm(), sizeof (srh->comm));
srh->start = gethrtime();
srh->objset = zb->zb_objset;
srh->object = zb->zb_object;
while (ssh->size > zfs_read_history) {
ssh->size--;
rm = list_remove_tail(&ssh->list);
- kmem_free(rm, sizeof(spa_read_history_t));
+ kmem_free(rm, sizeof (spa_read_history_t));
}
mutex_exit(&ssh->lock);
while ((sth = list_remove_head(&ssh->list))) {
ssh->size--;
- kmem_free(sth, sizeof(spa_txg_history_t));
+ kmem_free(sth, sizeof (spa_txg_history_t));
}
ASSERT3U(ssh->size, ==, 0);
}
ksp->ks_ndata = ssh->size;
- ksp->ks_data_size = ssh->size * sizeof(spa_txg_history_t);
+ ksp->ks_data_size = ssh->size * sizeof (spa_txg_history_t);
return (0);
}
mutex_enter(&ssh->lock);
while ((sth = list_remove_head(&ssh->list))) {
ssh->size--;
- kmem_free(sth, sizeof(spa_txg_history_t));
+ kmem_free(sth, sizeof (spa_txg_history_t));
}
ASSERT3U(ssh->size, ==, 0);
if (zfs_txg_history == 0 && ssh->size == 0)
return;
- sth = kmem_zalloc(sizeof(spa_txg_history_t), KM_PUSHPAGE);
+ sth = kmem_zalloc(sizeof (spa_txg_history_t), KM_PUSHPAGE);
sth->txg = txg;
sth->state = TXG_STATE_OPEN;
sth->times[TXG_STATE_BIRTH] = gethrtime();
while (ssh->size > zfs_txg_history) {
ssh->size--;
rm = list_remove_tail(&ssh->list);
- kmem_free(rm, sizeof(spa_txg_history_t));
+ kmem_free(rm, sizeof (spa_txg_history_t));
}
mutex_exit(&ssh->lock);
mutex_enter(&ssh->lock);
for (sth = list_head(&ssh->list); sth != NULL;
- sth = list_next(&ssh->list, sth)) {
+ sth = list_next(&ssh->list, sth)) {
if (sth->txg == txg) {
sth->times[completed_state] = completed_time;
sth->state++;
mutex_enter(&ssh->lock);
for (sth = list_head(&ssh->list); sth != NULL;
- sth = list_next(&ssh->list, sth)) {
+ sth = list_next(&ssh->list, sth)) {
if (sth->txg == txg) {
sth->nread = nread;
sth->nwritten = nwritten;
break;
ksp->ks_ndata = i;
- ksp->ks_data_size = i * sizeof(kstat_named_t);
+ ksp->ks_data_size = i * sizeof (kstat_named_t);
return (0);
}
mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
ssh->count = 42; /* power of two buckets for 1ns to 2,199s */
- ssh->size = ssh->count * sizeof(kstat_named_t);
+ ssh->size = ssh->count * sizeof (kstat_named_t);
ssh->private = kmem_alloc(ssh->size, KM_SLEEP);
(void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
txg_thread_enter(tx, &cpr);
- vs1 = kmem_alloc(sizeof(vdev_stat_t), KM_PUSHPAGE);
- vs2 = kmem_alloc(sizeof(vdev_stat_t), KM_PUSHPAGE);
+ vs1 = kmem_alloc(sizeof (vdev_stat_t), KM_PUSHPAGE);
+ vs2 = kmem_alloc(sizeof (vdev_stat_t), KM_PUSHPAGE);
start = delta = 0;
for (;;) {
}
if (tx->tx_exiting) {
- kmem_free(vs2, sizeof(vdev_stat_t));
- kmem_free(vs1, sizeof(vdev_stat_t));
+ kmem_free(vs2, sizeof (vdev_stat_t));
+ kmem_free(vs1, sizeof (vdev_stat_t));
txg_thread_exit(tx, &cpr, &tx->tx_sync_thread);
}
vdev_cache_t *vc = &zio->io_vd->vdev_cache;
vdev_cache_entry_t *ve, *ve_search;
uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
- ASSERTV(uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS);)
zio_t *fio;
+ ASSERTV(uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS));
ASSERT(zio->io_type == ZIO_TYPE_READ);
mutex_enter(&vc->vc_lock);
- ve_search = kmem_alloc(sizeof(vdev_cache_entry_t), KM_PUSHPAGE);
+ ve_search = kmem_alloc(sizeof (vdev_cache_entry_t), KM_PUSHPAGE);
ve_search->ve_offset = cache_offset;
ve = avl_find(&vc->vc_offset_tree, ve_search, NULL);
- kmem_free(ve_search, sizeof(vdev_cache_entry_t));
+ kmem_free(ve_search, sizeof (vdev_cache_entry_t));
if (ve != NULL) {
if (ve->ve_missed_update) {
int dr_rw; /* Read/Write */
int dr_error; /* Bio error */
int dr_bio_count; /* Count of bio's */
- struct bio *dr_bio[0]; /* Attached bio's */
+ struct bio *dr_bio[0]; /* Attached bio's */
} dio_request_t;
if (smode & FWRITE)
mode |= FMODE_WRITE;
- return mode;
+ return (mode);
}
#else
static int
if ((smode & FREAD) && !(smode & FWRITE))
mode = MS_RDONLY;
- return mode;
+ return (mode);
}
#endif /* HAVE_OPEN_BDEV_EXCLUSIVE */
return (0);
/* Leave existing scheduler when set to "none" */
- if (!strncmp(elevator, "none", 4) && (strlen(elevator) == 4))
+ if (strncmp(elevator, "none", 4) && (strlen(elevator) == 4) == 0)
return (0);
#ifdef HAVE_ELEVATOR_CHANGE
error = elevator_change(q, elevator);
#else
- /* For pre-2.6.36 kernels elevator_change() is not available.
+ /*
+ * For pre-2.6.36 kernels elevator_change() is not available.
* Therefore we fall back to using a usermodehelper to echo the
* elevator into sysfs; This requires /bin/echo and sysfs to be
* mounted which may not be true early in the boot process.
*/
-# define SET_SCHEDULER_CMD \
+#define SET_SCHEDULER_CMD \
"exec 0</dev/null " \
" 1>/sys/block/%s/queue/scheduler " \
" 2>/dev/null; " \
#endif /* HAVE_ELEVATOR_CHANGE */
if (error)
printk("ZFS: Unable to set \"%s\" scheduler for %s (%s): %d\n",
- elevator, v->vdev_path, device, error);
+ elevator, v->vdev_path, device, error);
return (error);
}
bdev = vdev_bdev_open(path, vdev_bdev_mode(mode), zfs_vdev_holder);
if (IS_ERR(bdev))
- return bdev;
+ return (bdev);
disk = get_gendisk(bdev->bd_dev, &partno);
vdev_bdev_close(bdev, vdev_bdev_mode(mode));
put_disk(disk);
}
- return result;
+ return (result);
#else
- return ERR_PTR(-EOPNOTSUPP);
+ return (ERR_PTR(-EOPNOTSUPP));
#endif /* defined(HAVE_3ARG_BLKDEV_GET) && defined(HAVE_GET_GENDISK) */
}
/* Must have a pathname and it must be absolute. */
if (v->vdev_path == NULL || v->vdev_path[0] != '/') {
v->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return EINVAL;
+ return (EINVAL);
}
/*
goto skip_open;
}
- vd = kmem_zalloc(sizeof(vdev_disk_t), KM_PUSHPAGE);
+ vd = kmem_zalloc(sizeof (vdev_disk_t), KM_PUSHPAGE);
if (vd == NULL)
- return ENOMEM;
+ return (ENOMEM);
/*
* Devices are always opened by the path provided at configuration
bdev = vdev_bdev_open(v->vdev_path,
vdev_bdev_mode(mode), zfs_vdev_holder);
if (IS_ERR(bdev)) {
- kmem_free(vd, sizeof(vdev_disk_t));
- return -PTR_ERR(bdev);
+ kmem_free(vd, sizeof (vdev_disk_t));
+ return (-PTR_ERR(bdev));
}
v->vdev_tsd = vd;
/* Try to set the io scheduler elevator algorithm */
(void) vdev_elevator_switch(v, zfs_vdev_scheduler);
- return 0;
+ return (0);
}
static void
if (vd->vd_bdev != NULL)
vdev_bdev_close(vd->vd_bdev,
- vdev_bdev_mode(spa_mode(v->vdev_spa)));
+ vdev_bdev_mode(spa_mode(v->vdev_spa)));
- kmem_free(vd, sizeof(vdev_disk_t));
+ kmem_free(vd, sizeof (vdev_disk_t));
v->vdev_tsd = NULL;
}
dio_request_t *dr;
int i;
- dr = kmem_zalloc(sizeof(dio_request_t) +
- sizeof(struct bio *) * bio_count, KM_PUSHPAGE);
+ dr = kmem_zalloc(sizeof (dio_request_t) +
+ sizeof (struct bio *) * bio_count, KM_PUSHPAGE);
if (dr) {
init_completion(&dr->dr_comp);
atomic_set(&dr->dr_ref, 0);
dr->dr_bio[i] = NULL;
}
- return dr;
+ return (dr);
}
static void
if (dr->dr_bio[i])
bio_put(dr->dr_bio[i]);
- kmem_free(dr, sizeof(dio_request_t) +
- sizeof(struct bio *) * dr->dr_bio_count);
+ kmem_free(dr, sizeof (dio_request_t) +
+ sizeof (struct bio *) * dr->dr_bio_count);
}
static int
{
#ifdef HAVE_BIO_RW_SYNC
/* BIO_RW_SYNC preferred interface from 2.6.12-2.6.29 */
- return (dr->dr_rw & (1 << BIO_RW_SYNC));
+ return (dr->dr_rw & (1 << BIO_RW_SYNC));
#else
-# ifdef HAVE_BIO_RW_SYNCIO
+#ifdef HAVE_BIO_RW_SYNCIO
/* BIO_RW_SYNCIO preferred interface from 2.6.30-2.6.35 */
- return (dr->dr_rw & (1 << BIO_RW_SYNCIO));
-# else
-# ifdef HAVE_REQ_SYNC
+ return (dr->dr_rw & (1 << BIO_RW_SYNCIO));
+#else
+#ifdef HAVE_REQ_SYNC
/* REQ_SYNC preferred interface from 2.6.36-2.6.xx */
- return (dr->dr_rw & REQ_SYNC);
-# else
-# error "Unable to determine bio sync flag"
-# endif /* HAVE_REQ_SYNC */
-# endif /* HAVE_BIO_RW_SYNC */
+ return (dr->dr_rw & REQ_SYNC);
+#else
+#error "Unable to determine bio sync flag"
+#endif /* HAVE_REQ_SYNC */
+#endif /* HAVE_BIO_RW_SYNC */
#endif /* HAVE_BIO_RW_SYNCIO */
}
}
}
- return rc;
+ return (rc);
}
BIO_END_IO_PROTO(vdev_disk_physio_completion, bio, size, error)
#ifndef HAVE_2ARGS_BIO_END_IO_T
if (bio->bi_size)
- return 1;
+ return (1);
#endif /* HAVE_2ARGS_BIO_END_IO_T */
if (error == 0 && !test_bit(BIO_UPTODATE, &bio->bi_flags))
- error = -EIO;
+ error = (-EIO);
if (dr->dr_error == 0)
dr->dr_error = -error;
bio_nr_pages(void *bio_ptr, unsigned int bio_size)
{
return ((((unsigned long)bio_ptr + bio_size + PAGE_SIZE - 1) >>
- PAGE_SHIFT) - ((unsigned long)bio_ptr >> PAGE_SHIFT));
+ PAGE_SHIFT) - ((unsigned long)bio_ptr >> PAGE_SHIFT));
}
static unsigned int
offset = 0;
}
- return bio_size;
+ return (bio_size);
}
static int
__vdev_disk_physio(struct block_device *bdev, zio_t *zio, caddr_t kbuf_ptr,
- size_t kbuf_size, uint64_t kbuf_offset, int flags)
+ size_t kbuf_size, uint64_t kbuf_offset, int flags)
{
- dio_request_t *dr;
+ dio_request_t *dr;
caddr_t bio_ptr;
uint64_t bio_offset;
int bio_size, bio_count = 16;
retry:
dr = vdev_disk_dio_alloc(bio_count);
if (dr == NULL)
- return ENOMEM;
+ return (ENOMEM);
if (zio && !(zio->io_flags & (ZIO_FLAG_IO_RETRY | ZIO_FLAG_TRYHARD)))
bio_set_flags_failfast(bdev, &flags);
}
dr->dr_bio[i] = bio_alloc(GFP_NOIO,
- bio_nr_pages(bio_ptr, bio_size));
+ bio_nr_pages(bio_ptr, bio_size));
if (dr->dr_bio[i] == NULL) {
vdev_disk_dio_free(dr);
- return ENOMEM;
+ return (ENOMEM);
}
/* Matching put called by vdev_disk_physio_completion */
ASSERT3S(atomic_read(&dr->dr_ref), ==, 1);
}
- (void)vdev_disk_dio_put(dr);
+ (void) vdev_disk_dio_put(dr);
- return error;
+ return (error);
}
int
vdev_disk_physio(struct block_device *bdev, caddr_t kbuf,
- size_t size, uint64_t offset, int flags)
+ size_t size, uint64_t offset, int flags)
{
bio_set_flags_failfast(bdev, &flags);
- return __vdev_disk_physio(bdev, NULL, kbuf, size, offset, flags);
+ return (__vdev_disk_physio(bdev, NULL, kbuf, size, offset, flags));
}
BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, size, rc)
q = bdev_get_queue(bdev);
if (!q)
- return ENXIO;
+ return (ENXIO);
bio = bio_alloc(GFP_NOIO, 0);
if (!bio)
- return ENOMEM;
+ return (ENOMEM);
bio->bi_end_io = vdev_disk_io_flush_completion;
bio->bi_private = zio;
zio->io_delay = jiffies_64;
submit_bio(VDEV_WRITE_FLUSH_FUA, bio);
- return 0;
+ return (0);
}
static int
if (!vdev_readable(v)) {
zio->io_error = SET_ERROR(ENXIO);
- return ZIO_PIPELINE_CONTINUE;
+ return (ZIO_PIPELINE_CONTINUE);
}
switch (zio->io_cmd) {
error = vdev_disk_io_flush(vd->vd_bdev, zio);
if (error == 0)
- return ZIO_PIPELINE_STOP;
+ return (ZIO_PIPELINE_STOP);
zio->io_error = error;
if (error == ENOTSUP)
zio->io_error = SET_ERROR(ENOTSUP);
}
- return ZIO_PIPELINE_CONTINUE;
+ return (ZIO_PIPELINE_CONTINUE);
case ZIO_TYPE_WRITE:
flags = WRITE;
default:
zio->io_error = SET_ERROR(ENOTSUP);
- return ZIO_PIPELINE_CONTINUE;
+ return (ZIO_PIPELINE_CONTINUE);
}
error = __vdev_disk_physio(vd->vd_bdev, zio, zio->io_data,
- zio->io_size, zio->io_offset, flags);
+ zio->io_size, zio->io_offset, flags);
if (error) {
zio->io_error = error;
- return ZIO_PIPELINE_CONTINUE;
+ return (ZIO_PIPELINE_CONTINUE);
}
- return ZIO_PIPELINE_STOP;
+ return (ZIO_PIPELINE_STOP);
}
static void
* removal of the device from the configuration.
*/
if (zio->io_error == EIO) {
- vdev_t *v = zio->io_vd;
+ vdev_t *v = zio->io_vd;
vdev_disk_t *vd = v->vdev_tsd;
if (check_disk_change(vd->vd_bdev)) {
bdev = vdev_bdev_open(devpath, vdev_bdev_mode(FREAD), zfs_vdev_holder);
if (IS_ERR(bdev))
- return -PTR_ERR(bdev);
+ return (-PTR_ERR(bdev));
s = bdev_capacity(bdev);
if (s == 0) {
vdev_bdev_close(bdev, vdev_bdev_mode(FREAD));
- return EIO;
+ return (EIO);
}
- size = P2ALIGN_TYPED(s, sizeof(vdev_label_t), uint64_t);
- label = vmem_alloc(sizeof(vdev_label_t), KM_PUSHPAGE);
+ size = P2ALIGN_TYPED(s, sizeof (vdev_label_t), uint64_t);
+ label = vmem_alloc(sizeof (vdev_label_t), KM_PUSHPAGE);
for (i = 0; i < VDEV_LABELS; i++) {
- uint64_t offset, state, txg = 0;
+ uint64_t offset, state, txg = 0;
/* read vdev label */
offset = vdev_label_offset(size, i, 0);
break;
}
- vmem_free(label, sizeof(vdev_label_t));
+ vmem_free(label, sizeof (vdev_label_t));
vdev_bdev_close(bdev, vdev_bdev_mode(FREAD));
- return 0;
+ return (0);
}
module_param(zfs_vdev_scheduler, charp, 0644);
buf = vp->vp_nvlist;
buflen = sizeof (vp->vp_nvlist);
- if (nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_PUSHPAGE) == 0) {
+ if (!nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_PUSHPAGE)) {
for (; l < VDEV_LABELS; l += 2) {
vdev_label_write(zio, vd, l, vp,
offsetof(vdev_label_t, vl_vdev_phys),
if (zio->io_flags & ZIO_FLAG_DONT_AGGREGATE)
return (NULL);
- /* Prevent users from setting the zfs_vdev_aggregation_limit
- * tuning larger than SPA_MAXBLOCKSIZE. */
+ /*
+ * Prevent users from setting the zfs_vdev_aggregation_limit
+ * tuning larger than SPA_MAXBLOCKSIZE.
+ */
zfs_vdev_aggregation_limit =
MIN(zfs_vdev_aggregation_limit, SPA_MAXBLOCKSIZE);
* For FIFO queues (sync), issue the i/o with the lowest timestamp.
*/
vqc = &vq->vq_class[p];
- search = zio_buf_alloc(sizeof(*search));
+ search = zio_buf_alloc(sizeof (*search));
search->io_timestamp = 0;
search->io_offset = vq->vq_last_offset + 1;
VERIFY3P(avl_find(&vqc->vqc_queued_tree, search, &idx), ==, NULL);
- zio_buf_free(search, sizeof(*search));
+ zio_buf_free(search, sizeof (*search));
zio = avl_nearest(&vqc->vqc_queued_tree, idx, AVL_AFTER);
if (zio == NULL)
zio = avl_first(&vqc->vqc_queued_tree);
module_param(zfs_vdev_async_write_active_max_dirty_percent, int, 0644);
MODULE_PARM_DESC(zfs_vdev_async_write_active_max_dirty_percent,
- "Async write concurrency max threshold");
+ "Async write concurrency max threshold");
module_param(zfs_vdev_async_write_active_min_dirty_percent, int, 0644);
MODULE_PARM_DESC(zfs_vdev_async_write_active_min_dirty_percent,
- "Async write concurrency min threshold");
+ "Async write concurrency min threshold");
module_param(zfs_vdev_async_read_max_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_async_read_max_active,
- "Max active async read I/Os per vdev");
+ "Max active async read I/Os per vdev");
module_param(zfs_vdev_async_read_min_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_async_read_min_active,
- "Min active async read I/Os per vdev");
+ "Min active async read I/Os per vdev");
module_param(zfs_vdev_async_write_max_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_async_write_max_active,
- "Max active async write I/Os per vdev");
+ "Max active async write I/Os per vdev");
module_param(zfs_vdev_async_write_min_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_async_write_min_active,
- "Min active async write I/Os per vdev");
+ "Min active async write I/Os per vdev");
module_param(zfs_vdev_scrub_max_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_scrub_max_active, "Max active scrub I/Os per vdev");
module_param(zfs_vdev_sync_read_max_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_sync_read_max_active,
- "Max active sync read I/Os per vdev");
+ "Max active sync read I/Os per vdev");
module_param(zfs_vdev_sync_read_min_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_sync_read_min_active,
- "Min active sync read I/Os per vdev");
+ "Min active sync read I/Os per vdev");
module_param(zfs_vdev_sync_write_max_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_sync_write_max_active,
- "Max active sync write I/Os per vdev");
+ "Max active sync write I/Os per vdev");
module_param(zfs_vdev_sync_write_min_active, int, 0644);
MODULE_PARM_DESC(zfs_vdev_sync_write_min_active,
- "Min active sync write I/Osper vdev");
+ "Min active sync write I/Osper vdev");
#endif
#ifdef ZFS_DEBUG
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
- ASSERTV(mzap_ent_phys_t *mze=&zap->zap_m.zap_phys->mz_chunk[i]);
+ ASSERTV(mzap_ent_phys_t *mze);
+ ASSERT(mze = &zap->zap_m.zap_phys->mz_chunk[i]);
ASSERT(strcmp(zn->zn_key_orig, mze->mze_name) != 0);
}
#endif
zap_attribute_t *za;
char *buf;
- zc = kmem_alloc(sizeof(zap_cursor_t), KM_SLEEP);
- za = kmem_alloc(sizeof(zap_attribute_t), KM_SLEEP);
+ zc = kmem_alloc(sizeof (zap_cursor_t), KM_SLEEP);
+ za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
buf = kmem_alloc(MAXPATHLEN, KM_SLEEP);
supported = B_TRUE;
zap_cursor_fini(zc);
kmem_free(buf, MAXPATHLEN);
- kmem_free(za, sizeof(zap_attribute_t));
- kmem_free(zc, sizeof(zap_cursor_t));
+ kmem_free(za, sizeof (zap_attribute_t));
+ kmem_free(zc, sizeof (zap_cursor_t));
return (supported);
}
int error;
zfs_acl_t *aclp;
- if (ZTOZSB(zp)->z_acl_type == ZFS_ACLTYPE_POSIXACL)
- return 0;
+ if (ZTOZSB(zp)->z_acl_type == ZFS_ACLTYPE_POSIXACL)
+ return (0);
ASSERT(MUTEX_HELD(&zp->z_lock));
ASSERT(MUTEX_HELD(&zp->z_acl_lock));
if ((error = zfs_acl_node_read(zp, B_TRUE, &aclp, B_FALSE)) == 0)
zp->z_mode = zfs_mode_compute(zp->z_mode, aclp,
&zp->z_pflags, zp->z_uid, zp->z_gid);
+
return (error);
}
*/
error = zfs_zget(ZTOZSB(zp), parent, &check_zp);
if (error)
- return (error);
+ return (error);
rw_enter(&zp->z_xattr_lock, RW_WRITER);
if (zp->z_xattr_parent == NULL)
static zfs_snapentry_t *
zfsctl_sep_alloc(void)
{
- return kmem_zalloc(sizeof (zfs_snapentry_t), KM_SLEEP);
+ return (kmem_zalloc(sizeof (zfs_snapentry_t), KM_SLEEP));
}
void
void
zfsctl_inode_destroy(struct inode *ip)
{
- return;
}
/*
mutex_destroy(&zfs_dbgmsgs_lock);
ASSERT0(zfs_dbgmsg_size);
#endif
- return;
}
#if !defined(_KERNEL) || !defined(__linux__)
return (PRIV_POLICY(cr, needed_priv, B_FALSE, EPERM, NULL));
return (0);
#else
- return ENOTSUP;
+ return (ENOTSUP);
#endif /* HAVE_MLSLABEL */
}
zfs_zevent_drain_all(&count);
zc->zc_cookie = count;
- return 0;
+ return (0);
}
/*
ASSERT(MUTEX_HELD(&zfsdev_state_lock));
for (zs = list_head(&zfsdev_state_list); zs != NULL;
- zs = list_next(&zfsdev_state_list, zs)) {
+ zs = list_next(&zfsdev_state_list, zs)) {
if (zs->zs_minor == minor) {
switch (which) {
- case ZST_ONEXIT: return (zs->zs_onexit);
- case ZST_ZEVENT: return (zs->zs_zevent);
- case ZST_ALL: return (zs);
+ case ZST_ONEXIT:
+ return (zs->zs_onexit);
+ case ZST_ZEVENT:
+ return (zs->zs_zevent);
+ case ZST_ALL:
+ return (zs);
}
}
}
- return NULL;
+ return (NULL);
}
void *
ptr = zfsdev_get_state_impl(minor, which);
mutex_exit(&zfsdev_state_lock);
- return ptr;
+ return (ptr);
}
minor_t
ASSERT(MUTEX_HELD(&zfsdev_state_lock));
- minor = zfsdev_minor_alloc();
- if (minor == 0)
- return (SET_ERROR(ENXIO));
+ minor = zfsdev_minor_alloc();
+ if (minor == 0)
+ return (SET_ERROR(ENXIO));
- zs = kmem_zalloc( sizeof(zfsdev_state_t), KM_SLEEP);
+ zs = kmem_zalloc(sizeof (zfsdev_state_t), KM_SLEEP);
zs->zs_file = filp;
zs->zs_minor = minor;
zfs_zevent_destroy(zs->zs_zevent);
list_remove(&zfsdev_state_list, zs);
- kmem_free(zs, sizeof(zfsdev_state_t));
+ kmem_free(zs, sizeof (zfsdev_state_t));
- return 0;
+ return (0);
}
static int
goto out;
/* legacy ioctls can modify zc_name */
- (void) strlcpy(saved_poolname, zc->zc_name, sizeof(saved_poolname));
+ (void) strlcpy(saved_poolname, zc->zc_name, sizeof (saved_poolname));
len = strcspn(saved_poolname, "/@") + 1;
saved_poolname[len] = '\0';
static long
zfsdev_compat_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
{
- return zfsdev_ioctl(filp, cmd, arg);
+ return (zfsdev_ioctl(filp, cmd, arg));
}
#else
-#define zfsdev_compat_ioctl NULL
+#define zfsdev_compat_ioctl NULL
#endif
static const struct file_operations zfsdev_fops = {
- .open = zfsdev_open,
- .release = zfsdev_release,
- .unlocked_ioctl = zfsdev_ioctl,
- .compat_ioctl = zfsdev_compat_ioctl,
- .owner = THIS_MODULE,
+ .open = zfsdev_open,
+ .release = zfsdev_release,
+ .unlocked_ioctl = zfsdev_ioctl,
+ .compat_ioctl = zfsdev_compat_ioctl,
+ .owner = THIS_MODULE,
};
static struct miscdevice zfs_misc = {
- .minor = MISC_DYNAMIC_MINOR,
- .name = ZFS_DRIVER,
- .fops = &zfsdev_fops,
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = ZFS_DRIVER,
+ .fops = &zfsdev_fops,
};
static int
offsetof(zfsdev_state_t, zs_next));
error = misc_register(&zfs_misc);
- if (error != 0) {
+ if (error != 0) {
printk(KERN_INFO "ZFS: misc_register() failed %d\n", error);
return (error);
}
}
#ifdef DEBUG
-#define ZFS_DEBUG_STR " (DEBUG mode)"
+#define ZFS_DEBUG_STR " (DEBUG mode)"
#else
-#define ZFS_DEBUG_STR ""
+#define ZFS_DEBUG_STR ""
#endif
int
tsd_create(&zfs_allow_log_key, zfs_allow_log_destroy);
printk(KERN_NOTICE "ZFS: Loaded module v%s-%s%s, "
- "ZFS pool version %s, ZFS filesystem version %s\n",
- ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR,
- SPA_VERSION_STRING, ZPL_VERSION_STRING);
+ "ZFS pool version %s, ZFS filesystem version %s\n",
+ ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR,
+ SPA_VERSION_STRING, ZPL_VERSION_STRING);
#ifndef CONFIG_FS_POSIX_ACL
printk(KERN_NOTICE "ZFS: Posix ACLs disabled by kernel\n");
#endif /* CONFIG_FS_POSIX_ACL */
zfs_fini();
spa_fini();
printk(KERN_NOTICE "ZFS: Failed to Load ZFS Filesystem v%s-%s%s"
- ", rc = %d\n", ZFS_META_VERSION, ZFS_META_RELEASE,
- ZFS_DEBUG_STR, error);
+ ", rc = %d\n", ZFS_META_VERSION, ZFS_META_RELEASE,
+ ZFS_DEBUG_STR, error);
return (error);
}
tsd_destroy(&zfs_allow_log_key);
printk(KERN_NOTICE "ZFS: Unloaded module v%s-%s%s\n",
- ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR);
+ ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR);
return (0);
}
ASSERT(rl->r_type == RL_WRITER || rl->r_type == RL_READER);
ASSERT(rl->r_cnt == 1 || rl->r_cnt == 0);
ASSERT(!rl->r_proxy);
- list_create(&free_list, sizeof(rl_t), offsetof(rl_t, rl_node));
+ list_create(&free_list, sizeof (rl_t), offsetof(rl_t, rl_node));
mutex_enter(&zp->z_range_lock);
if (rl->r_type == RL_WRITER) {
}
/* First do a bulk query of the attributes that aren't cached */
- bulk = kmem_alloc(sizeof(sa_bulk_attr_t) * 20, KM_SLEEP);
+ bulk = kmem_alloc(sizeof (sa_bulk_attr_t) * 20, KM_SLEEP);
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zsb), NULL, &mtime, 16);
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, &ctime, 16);
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zsb), NULL, &crtime, 16);
&znode_acl, 88);
if (sa_bulk_lookup_locked(hdl, bulk, count) != 0) {
- kmem_free(bulk, sizeof(sa_bulk_attr_t) * 20);
+ kmem_free(bulk, sizeof (sa_bulk_attr_t) * 20);
goto done;
}
* it is such a way to pick up an already existing layout number
*/
count = 0;
- sa_attrs = kmem_zalloc(sizeof(sa_bulk_attr_t) * 20, KM_SLEEP);
+ sa_attrs = kmem_zalloc(sizeof (sa_bulk_attr_t) * 20, KM_SLEEP);
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_MODE(zsb), NULL, &mode, 8);
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_SIZE(zsb), NULL,
&zp->z_size, 8);
znode_acl.z_acl_extern_obj, tx));
zp->z_is_sa = B_TRUE;
- kmem_free(sa_attrs, sizeof(sa_bulk_attr_t) * 20);
- kmem_free(bulk, sizeof(sa_bulk_attr_t) * 20);
+ kmem_free(sa_attrs, sizeof (sa_bulk_attr_t) * 20);
+ kmem_free(bulk, sizeof (sa_bulk_attr_t) * 20);
done:
if (drop_lock)
mutex_exit(&zp->z_lock);
atime_changed_cb(zsb, B_FALSE);
readonly_changed_cb(zsb, B_TRUE);
- if ((error = dsl_prop_get_integer(osname,"xattr",&pval,NULL)))
+ if ((error = dsl_prop_get_integer(osname,
+ "xattr", &pval, NULL)))
goto out;
xattr_changed_cb(zsb, pval);
- if ((error = dsl_prop_get_integer(osname,"acltype",&pval,NULL)))
+ if ((error = dsl_prop_get_integer(osname,
+ "acltype", &pval, NULL)))
goto out;
acltype_changed_cb(zsb, pval);
zsb->z_issnap = B_TRUE;
*/
xoap = xva_getxoptattr(xvap);
- tmpxvattr = kmem_alloc(sizeof(xvattr_t), KM_SLEEP);
+ tmpxvattr = kmem_alloc(sizeof (xvattr_t), KM_SLEEP);
xva_init(tmpxvattr);
- bulk = kmem_alloc(sizeof(sa_bulk_attr_t) * 7, KM_SLEEP);
- xattr_bulk = kmem_alloc(sizeof(sa_bulk_attr_t) * 7, KM_SLEEP);
+ bulk = kmem_alloc(sizeof (sa_bulk_attr_t) * 7, KM_SLEEP);
+ xattr_bulk = kmem_alloc(sizeof (sa_bulk_attr_t) * 7, KM_SLEEP);
/*
* Immutable files can only alter immutable bit and atime
* once large timestamps are fully supported.
*/
if (mask & (ATTR_ATIME | ATTR_MTIME)) {
- if (((mask & ATTR_ATIME) && TIMESPEC_OVERFLOW(&vap->va_atime)) ||
- ((mask & ATTR_MTIME) && TIMESPEC_OVERFLOW(&vap->va_mtime))) {
+ if (((mask & ATTR_ATIME) &&
+ TIMESPEC_OVERFLOW(&vap->va_atime)) ||
+ ((mask & ATTR_MTIME) &&
+ TIMESPEC_OVERFLOW(&vap->va_mtime))) {
err = EOVERFLOW;
goto out3;
}
zil_commit(zilog, 0);
out3:
- kmem_free(xattr_bulk, sizeof(sa_bulk_attr_t) * 7);
- kmem_free(bulk, sizeof(sa_bulk_attr_t) * 7);
- kmem_free(tmpxvattr, sizeof(xvattr_t));
+ kmem_free(xattr_bulk, sizeof (sa_bulk_attr_t) * 7);
+ kmem_free(bulk, sizeof (sa_bulk_attr_t) * 7);
+ kmem_free(tmpxvattr, sizeof (xvattr_t));
ZFS_EXIT(zsb);
return (err);
}
ASSERT(PageLocked(pp));
- pgoff = page_offset(pp); /* Page byte-offset in file */
- offset = i_size_read(ip); /* File length in bytes */
- pglen = MIN(PAGE_CACHE_SIZE, /* Page length in bytes */
+ pgoff = page_offset(pp); /* Page byte-offset in file */
+ offset = i_size_read(ip); /* File length in bytes */
+ pglen = MIN(PAGE_CACHE_SIZE, /* Page length in bytes */
P2ROUNDUP(offset, PAGE_CACHE_SIZE)-pgoff);
/* Page is beyond end of file */
static int
zfs_fillpage(struct inode *ip, struct page *pl[], int nr_pages)
{
- znode_t *zp = ITOZ(ip);
- zfs_sb_t *zsb = ITOZSB(ip);
- objset_t *os;
+ znode_t *zp = ITOZ(ip);
+ zfs_sb_t *zsb = ITOZSB(ip);
+ objset_t *os;
struct page *cur_pp;
- u_offset_t io_off, total;
- size_t io_len;
- loff_t i_size;
- unsigned page_idx;
- int err;
+ u_offset_t io_off, total;
+ size_t io_len;
+ loff_t i_size;
+ unsigned page_idx;
+ int err;
- os = zsb->z_os;
+ os = zsb->z_os;
io_len = nr_pages << PAGE_CACHE_SHIFT;
i_size = i_size_read(ip);
io_off = page_offset(pl[0]);
error:
unlock_new_inode(ip);
iput(ip);
- return NULL;
+ return (NULL);
}
/*
* order for DMU_OT_ZNODE is critical since it needs to be constructed
* in the old znode_phys_t format. Don't change this ordering
*/
- sa_attrs = kmem_alloc(sizeof(sa_bulk_attr_t) * ZPL_END, KM_PUSHPAGE);
+ sa_attrs = kmem_alloc(sizeof (sa_bulk_attr_t) * ZPL_END, KM_PUSHPAGE);
if (obj_type == DMU_OT_ZNODE) {
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_ATIME(zsb),
err = zfs_aclset_common(*zpp, acl_ids->z_aclp, cr, tx);
ASSERT0(err);
}
- kmem_free(sa_attrs, sizeof(sa_bulk_attr_t) * ZPL_END);
+ kmem_free(sa_attrs, sizeof (sa_bulk_attr_t) * ZPL_END);
ZFS_OBJ_HOLD_EXIT(zsb, obj);
}
* See zil.h for more information about these fields.
*/
zil_stats_t zil_stats = {
- { "zil_commit_count", KSTAT_DATA_UINT64 },
- { "zil_commit_writer_count", KSTAT_DATA_UINT64 },
- { "zil_itx_count", KSTAT_DATA_UINT64 },
- { "zil_itx_indirect_count", KSTAT_DATA_UINT64 },
- { "zil_itx_indirect_bytes", KSTAT_DATA_UINT64 },
- { "zil_itx_copied_count", KSTAT_DATA_UINT64 },
- { "zil_itx_copied_bytes", KSTAT_DATA_UINT64 },
- { "zil_itx_needcopy_count", KSTAT_DATA_UINT64 },
- { "zil_itx_needcopy_bytes", KSTAT_DATA_UINT64 },
- { "zil_itx_metaslab_normal_count", KSTAT_DATA_UINT64 },
- { "zil_itx_metaslab_normal_bytes", KSTAT_DATA_UINT64 },
- { "zil_itx_metaslab_slog_count", KSTAT_DATA_UINT64 },
- { "zil_itx_metaslab_slog_bytes", KSTAT_DATA_UINT64 },
+ { "zil_commit_count", KSTAT_DATA_UINT64 },
+ { "zil_commit_writer_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_indirect_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_indirect_bytes", KSTAT_DATA_UINT64 },
+ { "zil_itx_copied_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_copied_bytes", KSTAT_DATA_UINT64 },
+ { "zil_itx_needcopy_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_needcopy_bytes", KSTAT_DATA_UINT64 },
+ { "zil_itx_metaslab_normal_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_metaslab_normal_bytes", KSTAT_DATA_UINT64 },
+ { "zil_itx_metaslab_slog_count", KSTAT_DATA_UINT64 },
+ { "zil_itx_metaslab_slog_bytes", KSTAT_DATA_UINT64 },
};
static kstat_t *zil_ksp;
char *lrbuf, *lrp;
int error = 0;
- bzero(&next_blk, sizeof(blkptr_t));
+ bzero(&next_blk, sizeof (blkptr_t));
/*
* Old logs didn't record the maximum zh_claim_lr_seq.
use_slog = USE_SLOG(zilog);
error = zio_alloc_zil(spa, txg, bp, zil_blksz,
USE_SLOG(zilog));
- if (use_slog)
- {
+ if (use_slog) {
ZIL_STAT_BUMP(zil_itx_metaslab_slog_count);
ZIL_STAT_INCR(zil_itx_metaslab_slog_bytes, lwb->lwb_nused);
- }
- else
- {
+ } else {
ZIL_STAT_BUMP(zil_itx_metaslab_normal_count);
ZIL_STAT_INCR(zil_itx_metaslab_normal_bytes, lwb->lwb_nused);
}
dbuf = lr_buf + reclen;
lrw->lr_common.lrc_reclen += dlen;
ZIL_STAT_BUMP(zil_itx_needcopy_count);
- ZIL_STAT_INCR(zil_itx_needcopy_bytes, lrw->lr_length);
+ ZIL_STAT_INCR(zil_itx_needcopy_bytes,
+ lrw->lr_length);
} else {
ASSERT(itx->itx_wr_state == WR_INDIRECT);
dbuf = NULL;
ZIL_STAT_BUMP(zil_itx_indirect_count);
- ZIL_STAT_INCR(zil_itx_indirect_bytes, lrw->lr_length);
+ ZIL_STAT_INCR(zil_itx_indirect_bytes,
+ lrw->lr_length);
}
error = zilog->zl_get_data(
itx->itx_private, lrw, dbuf, lwb->lwb_zio);
}
ASSERT(itxg->itxg_sod == 0);
itxg->itxg_txg = txg;
- itxs = itxg->itxg_itxs = kmem_zalloc(sizeof (itxs_t), KM_PUSHPAGE);
+ itxs = itxg->itxg_itxs = kmem_zalloc(sizeof (itxs_t),
+ KM_PUSHPAGE);
list_create(&itxs->i_sync_list, sizeof (itx_t),
offsetof(itx_t, itx_node));
ian = avl_find(t, &foid, &where);
if (ian == NULL) {
- ian = kmem_alloc(sizeof (itx_async_node_t), KM_PUSHPAGE);
+ ian = kmem_alloc(sizeof (itx_async_node_t),
+ KM_PUSHPAGE);
list_create(&ian->ia_list, sizeof (itx_t),
offsetof(itx_t, itx_node));
ian->ia_foid = foid;
DTRACE_PROBE1(zil__cw1, zilog_t *, zilog);
for (itx = list_head(&zilog->zl_itx_commit_list); itx != NULL;
- itx = list_next(&zilog->zl_itx_commit_list, itx)) {
+ itx = list_next(&zilog->zl_itx_commit_list, itx)) {
txg = itx->itx_lr.lrc_txg;
ASSERT(txg);
sizeof (struct lwb), 0, NULL, NULL, NULL, NULL, NULL, 0);
zil_ksp = kstat_create("zfs", 0, "zil", "misc",
- KSTAT_TYPE_NAMED, sizeof(zil_stats) / sizeof(kstat_named_t),
+ KSTAT_TYPE_NAMED, sizeof (zil_stats) / sizeof (kstat_named_t),
KSTAT_FLAG_VIRTUAL);
if (zil_ksp != NULL) {
zio_cons, zio_dest, NULL, NULL, NULL, KMC_KMEM);
zio_link_cache = kmem_cache_create("zio_link_cache",
sizeof (zio_link_t), 0, NULL, NULL, NULL, NULL, NULL, KMC_KMEM);
- zio_vdev_cache = kmem_cache_create("zio_vdev_cache", sizeof(vdev_io_t),
+ zio_vdev_cache = kmem_cache_create("zio_vdev_cache", sizeof (vdev_io_t),
PAGESIZE, NULL, NULL, NULL, NULL, NULL, KMC_VMEM);
/*
zio_write_gang_member_ready(zio_t *zio)
{
zio_t *pio = zio_unique_parent(zio);
- ASSERTV(zio_t *gio = zio->io_gang_leader;)
dva_t *cdva = zio->io_bp->blk_dva;
dva_t *pdva = pio->io_bp->blk_dva;
uint64_t asize;
int d;
+ ASSERTV(zio_t *gio = zio->io_gang_leader);
if (BP_IS_HOLE(zio->io_bp))
return;
if (zio->io_bp != NULL) {
ASSERT(zio->io_bp->blk_pad[0] == 0);
ASSERT(zio->io_bp->blk_pad[1] == 0);
- ASSERT(bcmp(zio->io_bp, &zio->io_bp_copy, sizeof (blkptr_t)) == 0 ||
+ ASSERT(bcmp(zio->io_bp, &zio->io_bp_copy,
+ sizeof (blkptr_t)) == 0 ||
(zio->io_bp == zio_unique_parent(zio)->io_bp));
if (zio->io_type == ZIO_TYPE_WRITE && !BP_IS_HOLE(zio->io_bp) &&
zio->io_bp_override == NULL &&
!(zio->io_flags & ZIO_FLAG_IO_REPAIR)) {
ASSERT(!BP_SHOULD_BYTESWAP(zio->io_bp));
- ASSERT3U(zio->io_prop.zp_copies, <=, BP_GET_NDVAS(zio->io_bp));
+ ASSERT3U(zio->io_prop.zp_copies, <=,
+ BP_GET_NDVAS(zio->io_bp));
ASSERT(BP_COUNT_GANG(zio->io_bp) == 0 ||
- (BP_COUNT_GANG(zio->io_bp) == BP_GET_NDVAS(zio->io_bp)));
+ (BP_COUNT_GANG(zio->io_bp) ==
+ BP_GET_NDVAS(zio->io_bp)));
}
if (zio->io_flags & ZIO_FLAG_NOPWRITE)
VERIFY(BP_EQUAL(zio->io_bp, &zio->io_bp_orig));
if (asize != zio->io_size) {
abuf = zio_buf_alloc(asize);
bcopy(zio->io_data, abuf, zio->io_size);
- bzero(abuf + zio->io_size, asize - zio->io_size);
+ bzero(abuf+zio->io_size, asize-zio->io_size);
}
zio->io_cksum_report = zcr->zcr_next;
if (zio->io_delay >= MSEC_TO_TICK(zio_delay_max)) {
if (zio->io_vd != NULL && !vdev_is_dead(zio->io_vd))
zfs_ereport_post(FM_EREPORT_ZFS_DELAY, zio->io_spa,
- zio->io_vd, zio, 0, 0);
+ zio->io_vd, zio, 0, 0);
}
if (zio->io_error) {
* error and generate a logical data ereport.
*/
spa_log_error(zio->io_spa, zio);
- zfs_ereport_post(FM_EREPORT_ZFS_DATA, zio->io_spa, NULL, zio,
- 0, 0);
+ zfs_ereport_post(FM_EREPORT_ZFS_DATA, zio->io_spa,
+ NULL, zio, 0, 0);
}
}
module_param(zfs_sync_pass_deferred_free, int, 0644);
MODULE_PARM_DESC(zfs_sync_pass_deferred_free,
- "defer frees starting in this pass");
+ "Defer frees starting in this pass");
module_param(zfs_sync_pass_dont_compress, int, 0644);
MODULE_PARM_DESC(zfs_sync_pass_dont_compress,
- "don't compress starting in this pass");
+ "Don't compress starting in this pass");
module_param(zfs_sync_pass_rewrite, int, 0644);
MODULE_PARM_DESC(zfs_sync_pass_rewrite,
- "rewrite new bps starting in this pass");
+ "Rewrite new bps starting in this pass");
#endif
if (filp->f_mode & FMODE_WRITE)
return (-EACCES);
- return generic_file_open(ip, filp);
+ return (generic_file_open(ip, filp));
}
/*
if (error) {
if (error == -ENOENT)
- return d_splice_alias(NULL, dentry);
+ return (d_splice_alias(NULL, dentry));
else
- return ERR_PTR(error);
+ return (ERR_PTR(error));
}
- return d_splice_alias(ip, dentry);
+ return (d_splice_alias(ip, dentry));
}
/*
error = -zfsctl_mount_snapshot(path, 0);
dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
if (error)
- return ERR_PTR(error);
+ return (ERR_PTR(error));
/*
* Rather than returning the new vfsmount for the snapshot we must
zpl_snapdir_revalidate(struct dentry *dentry, unsigned int flags)
#endif
{
- return 0;
+ return (0);
}
dentry_operations_t zpl_dops_snapdirs = {
crfree(cr);
if (error && error != -ENOENT)
- return ERR_PTR(error);
+ return (ERR_PTR(error));
ASSERT(error == 0 || ip == NULL);
d_clear_d_op(dentry);
d_set_d_op(dentry, &zpl_dops_snapdirs);
- return d_splice_alias(ip, dentry);
+ return (d_splice_alias(ip, dentry));
}
static int
int error;
crhold(cr);
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
zpl_vap_init(vap, dip, mode | S_IFDIR, cr);
error = -zfsctl_snapdir_mkdir(dip, dname(dentry), vap, &ip, cr, 0);
d_instantiate(dentry, ip);
}
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
ASSERT3S(error, <=, 0);
crfree(cr);
if (error) {
if (error == -ENOENT)
- return d_splice_alias(NULL, dentry);
+ return (d_splice_alias(NULL, dentry));
else
- return ERR_PTR(error);
+ return (ERR_PTR(error));
}
- return d_splice_alias(ip, dentry);
+ return (d_splice_alias(ip, dentry));
}
static int
len_bytes = *max_len * sizeof (__u32);
if (len_bytes < offsetof(fid_t, fid_data))
- return 255;
+ return (255);
fid->fid_len = len_bytes - offsetof(fid_t, fid_data);
}
#endif /* HAVE_D_OBTAIN_ALIAS */
- return result;
+ return (result);
}
static struct dentry *
if (fh_type != FILEID_INO32_GEN ||
len_bytes < offsetof(fid_t, fid_data) ||
len_bytes < offsetof(fid_t, fid_data) + fid->fid_len)
- return ERR_PTR(-EINVAL);
+ return (ERR_PTR(-EINVAL));
rc = zfs_vget(sb, &ip, fid);
if (rc != 0)
- return ERR_PTR(-rc);
+ return (ERR_PTR(-rc));
ASSERT((ip != NULL) && !IS_ERR(ip));
- return zpl_dentry_obtain_alias(ip);
+ return (zpl_dentry_obtain_alias(ip));
}
static struct dentry *
ASSERT3S(error, <=, 0);
if (error)
- return ERR_PTR(error);
+ return (ERR_PTR(error));
- return zpl_dentry_obtain_alias(ip);
+ return (zpl_dentry_obtain_alias(ip));
}
#ifdef HAVE_COMMIT_METADATA
crfree(cr);
ASSERT3S(error, <=, 0);
- return error;
+ return (error);
}
#endif /* HAVE_COMMIT_METADATA */
const struct export_operations zpl_export_operations = {
- .encode_fh = zpl_encode_fh,
- .fh_to_dentry = zpl_fh_to_dentry,
- .get_parent = zpl_get_parent,
+ .encode_fh = zpl_encode_fh,
+ .fh_to_dentry = zpl_fh_to_dentry,
+ .get_parent = zpl_get_parent,
#ifdef HAVE_COMMIT_METADATA
- .commit_metadata= zpl_commit_metadata,
+ .commit_metadata = zpl_commit_metadata,
#endif /* HAVE_COMMIT_METADATA */
};
ssize_t
zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
- uio_seg_t segment, int flags, cred_t *cr)
+ uio_seg_t segment, int flags, cred_t *cr)
{
int error;
ssize_t read;
}
#endif /* SEEK_HOLE && SEEK_DATA */
- return generic_file_llseek(filp, offset, whence);
+ return (generic_file_llseek(filp, offset, whence));
}
/*
}
unlock_page(pp);
- return error;
+ return (error);
}
/*
static long
zpl_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
- return zpl_ioctl(filp, cmd, arg);
+ return (zpl_ioctl(filp, cmd, arg));
}
#endif /* CONFIG_COMPAT */
.readpages = zpl_readpages,
.readpage = zpl_readpage,
.writepage = zpl_writepage,
- .writepages = zpl_writepages,
+ .writepages = zpl_writepages,
};
const struct file_operations zpl_file_operations = {
.mmap = zpl_mmap,
.fsync = zpl_fsync,
#ifdef HAVE_FILE_FALLOCATE
- .fallocate = zpl_fallocate,
+ .fallocate = zpl_fallocate,
#endif /* HAVE_FILE_FALLOCATE */
- .unlocked_ioctl = zpl_ioctl,
+ .unlocked_ioctl = zpl_ioctl,
#ifdef CONFIG_COMPAT
- .compat_ioctl = zpl_compat_ioctl,
+ .compat_ioctl = zpl_compat_ioctl,
#endif
};
int error;
if (dlen(dentry) > ZFS_MAXNAMELEN)
- return ERR_PTR(-ENAMETOOLONG);
+ return (ERR_PTR(-ENAMETOOLONG));
crhold(cr);
error = -zfs_lookup(dir, dname(dentry), &ip, 0, cr, NULL, NULL);
if (error) {
if (error == -ENOENT)
- return d_splice_alias(NULL, dentry);
+ return (d_splice_alias(NULL, dentry));
else
- return ERR_PTR(error);
+ return (ERR_PTR(error));
}
- return d_splice_alias(ip, dentry);
+ return (d_splice_alias(ip, dentry));
}
void
int error;
crhold(cr);
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
zpl_vap_init(vap, dir, mode, cr);
error = -zfs_create(dir, dname(dentry), vap, 0, mode, &ip, cr, 0, NULL);
d_instantiate(dentry, ip);
}
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
ASSERT(rdev == 0);
crhold(cr);
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
zpl_vap_init(vap, dir, mode, cr);
vap->va_rdev = rdev;
d_instantiate(dentry, ip);
}
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
int error;
crhold(cr);
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
zpl_vap_init(vap, dir, mode | S_IFDIR, cr);
error = -zfs_mkdir(dir, dname(dentry), vap, &ip, cr, 0, NULL);
d_instantiate(dentry, ip);
}
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
crhold(cr);
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
vap->va_mask = ia->ia_valid & ATTR_IATTR_MASK;
vap->va_mode = ia->ia_mode;
vap->va_uid = KUID_TO_SUID(ia->ia_uid);
if (!error && (ia->ia_valid & ATTR_MODE))
error = zpl_chmod_acl(ip);
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
int error;
crhold(cr);
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
zpl_vap_init(vap, dir, S_IFLNK | S_IRWXUGO, cr);
error = -zfs_symlink(dir, dname(dentry), vap, (char *)name, &ip, cr, 0);
d_instantiate(dentry, ip);
}
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
int error;
if (ip->i_nlink >= ZFS_LINK_MAX)
- return -EMLINK;
+ return (-EMLINK);
crhold(cr);
ip->i_ctime = CURRENT_TIME_SEC;
#ifdef HAVE_INODE_TRUNCATE_RANGE
static void
-zpl_truncate_range(struct inode* ip, loff_t start, loff_t end)
+zpl_truncate_range(struct inode *ip, loff_t start, loff_t end)
{
cred_t *cr = CRED();
flock64_t bf;
static long
zpl_fallocate(struct inode *ip, int mode, loff_t offset, loff_t len)
{
- return zpl_fallocate_common(ip, mode, offset, len);
+ return (zpl_fallocate_common(ip, mode, offset, len));
}
#endif /* HAVE_INODE_FALLOCATE */
static void
zpl_inode_destroy(struct inode *ip)
{
- ASSERT(atomic_read(&ip->i_count) == 0);
+ ASSERT(atomic_read(&ip->i_count) == 0);
zfs_inode_destroy(ip);
}
static int
zpl_show_options(struct seq_file *seq, struct dentry *root)
{
- return __zpl_show_options(seq, root->d_sb->s_fs_info);
+ return (__zpl_show_options(seq, root->d_sb->s_fs_info));
}
#else
static int
zpl_show_options(struct seq_file *seq, struct vfsmount *vfsp)
{
- return __zpl_show_options(seq, vfsp->mnt_sb->s_fs_info);
+ return (__zpl_show_options(seq, vfsp->mnt_sb->s_fs_info));
}
#endif /* HAVE_SHOW_OPTIONS_WITH_DENTRY */
{
zpl_mount_data_t zmd = { osname, data };
- return mount_nodev(fs_type, flags, &zmd, zpl_fill_super);
+ return (mount_nodev(fs_type, flags, &zmd, zpl_fill_super));
}
#else
static int
{
zpl_mount_data_t zmd = { osname, data };
- return get_sb_nodev(fs_type, flags, &zmd, zpl_fill_super, mnt);
+ return (get_sb_nodev(fs_type, flags, &zmd, zpl_fill_super, mnt));
}
#endif /* HAVE_MOUNT_NODEV */
error = -zfs_sb_prune(sb, *(unsigned long *)arg, &objects);
ASSERT3S(error, <=, 0);
-
- return;
}
void
zpl_prune_sbs(int64_t bytes_to_scan, void *private)
{
- unsigned long nr_to_scan = (bytes_to_scan / sizeof(znode_t));
+ unsigned long nr_to_scan = (bytes_to_scan / sizeof (znode_t));
iterate_supers_type(&zpl_fs_type, zpl_prune_sb, &nr_to_scan);
kmem_reap();
void
zpl_prune_sbs(int64_t bytes_to_scan, void *private)
{
- unsigned long nr_to_scan = (bytes_to_scan / sizeof(znode_t));
+ unsigned long nr_to_scan = (bytes_to_scan / sizeof (znode_t));
- shrink_dcache_memory(nr_to_scan, GFP_KERNEL);
- shrink_icache_memory(nr_to_scan, GFP_KERNEL);
- kmem_reap();
+ shrink_dcache_memory(nr_to_scan, GFP_KERNEL);
+ shrink_icache_memory(nr_to_scan, GFP_KERNEL);
+ kmem_reap();
}
#endif /* HAVE_SHRINK */
static void
zpl_free_cached_objects(struct super_block *sb, int nr_to_scan)
{
- arc_adjust_meta(nr_to_scan * sizeof(znode_t), B_FALSE);
+ arc_adjust_meta(nr_to_scan * sizeof (znode_t), B_FALSE);
}
#endif /* HAVE_FREE_CACHED_OBJECTS */
static int
zpl_xattr_filldir(xattr_filldir_t *xf, const char *name, int name_len)
{
- if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN))
+ if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) == 0)
if (!(ITOZSB(xf->inode)->z_flags & ZSB_XATTR))
return (0);
- if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
+ if (strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0)
if (!capable(CAP_SYS_ADMIN))
return (0);
ASSERT3U(nvpair_type(nvp), ==, DATA_TYPE_BYTE_ARRAY);
error = zpl_xattr_filldir(xf, nvpair_name(nvp),
- strlen(nvpair_name(nvp)));
+ strlen(nvpair_name(nvp)));
if (error)
return (error);
}
/* Lookup failed create a new xattr. */
if (xip == NULL) {
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
vap->va_mode = xattr_mode;
vap->va_mask = ATTR_MODE;
vap->va_uid = crgetfsuid(cr);
out:
if (vap)
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
if (xip)
iput(xip);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
if (!(ITOZSB(ip)->z_flags & ZSB_XATTR))
- return -EOPNOTSUPP;
+ return (-EOPNOTSUPP);
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
if (!(ITOZSB(ip)->z_flags & ZSB_XATTR))
- return -EOPNOTSUPP;
+ return (-EOPNOTSUPP);
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags);
int error;
if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
+ return (-EACCES);
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size);
int error;
if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
+ return (-EACCES);
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags);
char *name;
error = zpl_security_inode_init_security(ip, dip, qstr,
- &name, &value, &len);
+ &name, &value, &len);
if (error) {
if (error == -EOPNOTSUPP)
- return 0;
+ return (0);
+
return (error);
}
if (S_ISLNK(ip->i_mode))
return (-EOPNOTSUPP);
- switch(type) {
+ switch (type) {
case ACL_TYPE_ACCESS:
name = POSIX_ACL_XATTR_ACCESS;
if (acl) {
name = POSIX_ACL_XATTR_DEFAULT;
break;
default:
- return ERR_PTR(-EINVAL);
+ return (ERR_PTR(-EINVAL));
}
size = zpl_xattr_get(ip, name, NULL, 0);
int
zpl_check_acl(struct inode *ip, int mask, unsigned int flags)
{
- return __zpl_check_acl(ip, mask);
+ return (__zpl_check_acl(ip, mask));
}
#elif defined(HAVE_CHECK_ACL)
int
zpl_check_acl(struct inode *ip, int mask)
{
- return __zpl_check_acl(ip , mask);
+ return (__zpl_check_acl(ip, mask));
}
#elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
int
zpl_permission(struct inode *ip, int mask, struct nameidata *nd)
{
- return generic_permission(ip, mask, __zpl_check_acl);
+ return (generic_permission(ip, mask, __zpl_check_acl));
}
#elif defined(HAVE_PERMISSION)
int
zpl_permission(struct inode *ip, int mask)
{
- return generic_permission(ip, mask, __zpl_check_acl);
+ return (generic_permission(ip, mask, __zpl_check_acl));
}
#endif /* HAVE_CHECK_ACL | HAVE_PERMISSION */
#endif /* !HAVE_GET_ACL */
}
mode = ip->i_mode;
- error = posix_acl_create(&acl,GFP_KERNEL, &mode);
+ error = posix_acl_create(&acl, GFP_KERNEL, &mode);
if (error >= 0) {
ip->i_mode = mode;
mark_inode_dirty(ip);
if (IS_ERR(acl) || !acl)
return (PTR_ERR(acl));
- error = posix_acl_chmod(&acl,GFP_KERNEL, ip->i_mode);
+ error = posix_acl_chmod(&acl, GFP_KERNEL, ip->i_mode);
if (!error)
- error = zpl_set_acl(ip,ACL_TYPE_ACCESS, acl);
+ error = zpl_set_acl(ip, ACL_TYPE_ACCESS, acl);
zpl_posix_acl_release(acl);
switch (type) {
case ACL_TYPE_ACCESS:
xattr_name = POSIX_ACL_XATTR_ACCESS;
- xattr_size = sizeof(xattr_name);
+ xattr_size = sizeof (xattr_name);
break;
case ACL_TYPE_DEFAULT:
xattr_name = POSIX_ACL_XATTR_DEFAULT;
- xattr_size = sizeof(xattr_name);
+ xattr_size = sizeof (xattr_name);
break;
default:
return (0);
void *buffer, size_t size, int type)
{
ASSERT3S(type, ==, ACL_TYPE_ACCESS);
- return zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type);
+ return (zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type));
}
static int
void *buffer, size_t size, int type)
{
ASSERT3S(type, ==, ACL_TYPE_DEFAULT);
- return zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type);
+ return (zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type));
}
#else
zpl_xattr_acl_get_access(struct inode *ip, const char *name,
void *buffer, size_t size)
{
- return zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_ACCESS);
+ return (zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_ACCESS));
}
static int
zpl_xattr_acl_get_default(struct inode *ip, const char *name,
void *buffer, size_t size)
{
- return zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_DEFAULT);
+ return (zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_DEFAULT));
}
#endif /* HAVE_DENTRY_XATTR_GET */
zpl_xattr_acl_set_access(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
{
- ASSERT3S(type, ==, ACL_TYPE_ACCESS);
- return zpl_xattr_acl_set(dentry->d_inode,
- name, value, size, flags, type);
+ ASSERT3S(type, ==, ACL_TYPE_ACCESS);
+ return (zpl_xattr_acl_set(dentry->d_inode,
+ name, value, size, flags, type));
}
static int
zpl_xattr_acl_set_default(struct dentry *dentry, const char *name,
- const void *value, size_t size,int flags, int type)
+ const void *value, size_t size, int flags, int type)
{
- ASSERT3S(type, ==, ACL_TYPE_DEFAULT);
- return zpl_xattr_acl_set(dentry->d_inode,
+ ASSERT3S(type, ==, ACL_TYPE_DEFAULT);
+ return zpl_xattr_acl_set(dentry->d_inode,
name, value, size, flags, type);
}
zpl_xattr_acl_set_access(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
- return zpl_xattr_acl_set(ip,
+ return zpl_xattr_acl_set(ip,
name, value, size, flags, ACL_TYPE_ACCESS);
}
zpl_xattr_acl_set_default(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
- return zpl_xattr_acl_set(ip,
+ return zpl_xattr_acl_set(ip,
name, value, size, flags, ACL_TYPE_DEFAULT);
}
#endif /* HAVE_DENTRY_XATTR_SET */
-/*****************************************************************************\
+/*
* ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space.
*
* You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
#include <sys/zfs_context.h>
#include <sys/dmu.h>
static spl_device *zpios_device;
static char *zpios_tag = "zpios_tag";
-static
-int zpios_upcall(char *path, char *phase, run_args_t *run_args, int rc)
+static int
+zpios_upcall(char *path, char *phase, run_args_t *run_args, int rc)
{
- /* This is stack heavy but it should be OK since we are only
+ /*
+ * This is stack heavy but it should be OK since we are only
* making the upcall between tests when the stack is shallow.
*/
- char id[16], chunk_size[16], region_size[16], thread_count[16];
+ char id[16], chunk_size[16], region_size[16], thread_count[16];
char region_count[16], offset[16], region_noise[16], chunk_noise[16];
- char thread_delay[16], flags[16], result[8];
- char *argv[16], *envp[4];
+ char thread_delay[16], flags[16], result[8];
+ char *argv[16], *envp[4];
if ((path == NULL) || (strlen(path) == 0))
- return -ENOENT;
+ return (-ENOENT);
snprintf(id, 15, "%d", run_args->id);
snprintf(chunk_size, 15, "%lu", (long unsigned)run_args->chunk_size);
- snprintf(region_size, 15, "%lu",(long unsigned) run_args->region_size);
+ snprintf(region_size, 15, "%lu", (long unsigned) run_args->region_size);
snprintf(thread_count, 15, "%u", run_args->thread_count);
snprintf(region_count, 15, "%u", run_args->region_count);
snprintf(offset, 15, "%lu", (long unsigned)run_args->offset);
snprintf(result, 7, "%d", rc);
/* Passing 15 args to registered pre/post upcall */
- argv[0] = path;
+ argv[0] = path;
argv[1] = phase;
argv[2] = strlen(run_args->log) ? run_args->log : "<none>";
argv[3] = id;
argv[15] = NULL;
/* Passing environment for user space upcall */
- envp[0] = "HOME=/";
- envp[1] = "TERM=linux";
- envp[2] = "PATH=/sbin:/usr/sbin:/bin:/usr/bin";
- envp[3] = NULL;
+ envp[0] = "HOME=/";
+ envp[1] = "TERM=linux";
+ envp[2] = "PATH=/sbin:/usr/sbin:/bin:/usr/bin";
+ envp[3] = NULL;
- return call_usermodehelper(path, argv, envp, UMH_WAIT_PROC);
+ return (call_usermodehelper(path, argv, envp, UMH_WAIT_PROC));
+}
+
+static int
+zpios_print(struct file *file, const char *format, ...)
+{
+ zpios_info_t *info = (zpios_info_t *)file->private_data;
+ va_list adx;
+ int rc;
+
+ ASSERT(info);
+ ASSERT(info->info_buffer);
+
+ va_start(adx, format);
+ spin_lock(&info->info_lock);
+
+ /* Don't allow the kernel to start a write in the red zone */
+ if ((int)(info->info_head - info->info_buffer) >
+ (info->info_size - ZPIOS_INFO_BUFFER_REDZONE)) {
+ rc = -EOVERFLOW;
+ } else {
+ rc = vsprintf(info->info_head, format, adx);
+ if (rc >= 0)
+ info->info_head += rc;
+ }
+
+ spin_unlock(&info->info_lock);
+ va_end(adx);
+
+ return (rc);
}
static uint64_t
zpios_dmu_object_create(run_args_t *run_args, objset_t *os)
{
struct dmu_tx *tx;
- uint64_t obj = 0ULL;
+ uint64_t obj = 0ULL;
int rc;
tx = dmu_tx_create(os);
rc = dmu_tx_assign(tx, TXG_WAIT);
if (rc) {
zpios_print(run_args->file,
- "dmu_tx_assign() failed: %d\n", rc);
+ "dmu_tx_assign() failed: %d\n", rc);
dmu_tx_abort(tx);
- return obj;
+ return (obj);
}
- obj = dmu_object_alloc(os, DMU_OT_UINT64_OTHER, 0,
- DMU_OT_NONE, 0, tx);
+ obj = dmu_object_alloc(os, DMU_OT_UINT64_OTHER, 0, DMU_OT_NONE, 0, tx);
rc = dmu_object_set_blocksize(os, obj, 128ULL << 10, 0, tx);
if (rc) {
zpios_print(run_args->file,
"dmu_object_set_blocksize() failed: %d\n", rc);
- dmu_tx_abort(tx);
- return obj;
+ dmu_tx_abort(tx);
+ return (obj);
}
dmu_tx_commit(tx);
- return obj;
+ return (obj);
}
static int
int rc;
tx = dmu_tx_create(os);
- dmu_tx_hold_free(tx, obj, 0, DMU_OBJECT_END);
+ dmu_tx_hold_free(tx, obj, 0, DMU_OBJECT_END);
rc = dmu_tx_assign(tx, TXG_WAIT);
if (rc) {
zpios_print(run_args->file,
"dmu_tx_assign() failed: %d\n", rc);
dmu_tx_abort(tx);
- return rc;
+ return (rc);
}
rc = dmu_object_free(os, obj, tx);
if (rc) {
zpios_print(run_args->file,
"dmu_object_free() failed: %d\n", rc);
- dmu_tx_abort(tx);
- return rc;
+ dmu_tx_abort(tx);
+ return (rc);
}
dmu_tx_commit(tx);
- return 0;
+ return (0);
}
static int
uint64_t obj = 0ULL;
int i, rc = 0, rc2;
- (void)zpios_upcall(run_args->pre, PHASE_PRE_CREATE, run_args, 0);
+ (void) zpios_upcall(run_args->pre, PHASE_PRE_CREATE, run_args, 0);
t->start = zpios_timespec_now();
- (void)snprintf(name, 32, "%s/id_%d", run_args->pool, run_args->id);
+ (void) snprintf(name, 32, "%s/id_%d", run_args->pool, run_args->id);
rc = dmu_objset_create(name, DMU_OST_OTHER, 0, NULL, NULL);
if (rc) {
zpios_print(run_args->file, "Error dmu_objset_create(%s, ...) "
goto out;
}
- rc = dmu_objset_own(name, DMU_OST_OTHER, 0, zpios_tag, &os);
- if (rc) {
+ rc = dmu_objset_own(name, DMU_OST_OTHER, 0, zpios_tag, &os);
+ if (rc) {
zpios_print(run_args->file, "Error dmu_objset_own(%s, ...) "
"failed: %d\n", name, rc);
goto out_destroy;
- }
+ }
if (!(run_args->flags & DMU_FPP)) {
obj = zpios_dmu_object_create(run_args, os);
zpios_region_t *region;
region = &run_args->regions[i];
- mutex_init(®ion->lock, NULL, MUTEX_DEFAULT, NULL);
+ mutex_init(®ion->lock, NULL, MUTEX_DEFAULT, NULL);
if (run_args->flags & DMU_FPP) {
/* File per process */
region->rd_offset = run_args->offset;
region->init_offset = run_args->offset;
region->max_offset = run_args->offset +
- run_args->region_size;
+ run_args->region_size;
} else {
/* Single shared file */
region->obj.os = os;
region->rd_offset = run_args->offset * i;
region->init_offset = run_args->offset * i;
region->max_offset = run_args->offset *
- i + run_args->region_size;
+ i + run_args->region_size;
}
}
out:
t->stop = zpios_timespec_now();
t->delta = zpios_timespec_sub(t->stop, t->start);
- (void)zpios_upcall(run_args->post, PHASE_POST_CREATE, run_args, rc);
+ (void) zpios_upcall(run_args->post, PHASE_POST_CREATE, run_args, rc);
- return rc;
+ return (rc);
}
static int
run_args_t *ra;
int rc, size;
- size = sizeof(*ra) + kcmd->cmd_region_count * sizeof(zpios_region_t);
+ size = sizeof (*ra) + kcmd->cmd_region_count * sizeof (zpios_region_t);
ra = vmem_zalloc(size, KM_SLEEP);
if (ra == NULL) {
zpios_print(file, "Unable to vmem_zalloc() %d bytes "
"for regions\n", size);
- return -ENOMEM;
+ return (-ENOMEM);
}
*run_args = ra;
strncpy(ra->pre, kcmd->cmd_pre, ZPIOS_PATH_SIZE - 1);
strncpy(ra->post, kcmd->cmd_post, ZPIOS_PATH_SIZE - 1);
strncpy(ra->log, kcmd->cmd_log, ZPIOS_PATH_SIZE - 1);
- ra->id = kcmd->cmd_id;
- ra->chunk_size = kcmd->cmd_chunk_size;
- ra->thread_count = kcmd->cmd_thread_count;
- ra->region_count = kcmd->cmd_region_count;
- ra->region_size = kcmd->cmd_region_size;
- ra->offset = kcmd->cmd_offset;
- ra->region_noise = kcmd->cmd_region_noise;
- ra->chunk_noise = kcmd->cmd_chunk_noise;
- ra->thread_delay = kcmd->cmd_thread_delay;
- ra->flags = kcmd->cmd_flags;
- ra->stats.wr_data = 0;
- ra->stats.wr_chunks = 0;
- ra->stats.rd_data = 0;
- ra->stats.rd_chunks = 0;
- ra->region_next = 0;
- ra->file = file;
- mutex_init(&ra->lock_work, NULL, MUTEX_DEFAULT, NULL);
- mutex_init(&ra->lock_ctl, NULL, MUTEX_DEFAULT, NULL);
-
- (void)zpios_upcall(ra->pre, PHASE_PRE_RUN, ra, 0);
+ ra->id = kcmd->cmd_id;
+ ra->chunk_size = kcmd->cmd_chunk_size;
+ ra->thread_count = kcmd->cmd_thread_count;
+ ra->region_count = kcmd->cmd_region_count;
+ ra->region_size = kcmd->cmd_region_size;
+ ra->offset = kcmd->cmd_offset;
+ ra->region_noise = kcmd->cmd_region_noise;
+ ra->chunk_noise = kcmd->cmd_chunk_noise;
+ ra->thread_delay = kcmd->cmd_thread_delay;
+ ra->flags = kcmd->cmd_flags;
+ ra->stats.wr_data = 0;
+ ra->stats.wr_chunks = 0;
+ ra->stats.rd_data = 0;
+ ra->stats.rd_chunks = 0;
+ ra->region_next = 0;
+ ra->file = file;
+ mutex_init(&ra->lock_work, NULL, MUTEX_DEFAULT, NULL);
+ mutex_init(&ra->lock_ctl, NULL, MUTEX_DEFAULT, NULL);
+
+ (void) zpios_upcall(ra->pre, PHASE_PRE_RUN, ra, 0);
rc = zpios_dmu_setup(ra);
if (rc) {
- mutex_destroy(&ra->lock_ctl);
- mutex_destroy(&ra->lock_work);
+ mutex_destroy(&ra->lock_ctl);
+ mutex_destroy(&ra->lock_work);
vmem_free(ra, size);
*run_args = NULL;
}
- return rc;
+ return (rc);
}
static int
int i, j, count = 0;
unsigned int random_int;
- get_random_bytes(&random_int, sizeof(unsigned int));
+ get_random_bytes(&random_int, sizeof (unsigned int));
mutex_enter(&run_args->lock_work);
i = run_args->region_next;
- /* XXX: I don't much care for this chunk selection mechansim
+ /*
+ * XXX: I don't much care for this chunk selection mechansim
* there's the potential to burn a lot of time here doing nothing
* useful while holding the global lock. This could give some
* misleading performance results. I'll fix it latter.
/* update ctl structure */
if (run_args->region_noise) {
- get_random_bytes(&random_int, sizeof(unsigned int));
- run_args->region_next += random_int % run_args->region_noise;
+ get_random_bytes(&random_int, sizeof (unsigned int));
+ run_args->region_next +=
+ random_int % run_args->region_noise;
} else {
run_args->region_next++;
}
mutex_exit(&run_args->lock_work);
- return 1;
+ return (1);
}
/* nothing left to do */
mutex_exit(&run_args->lock_work);
- return 0;
+ return (0);
}
static void
char name[32];
int rc = 0, i;
- (void)zpios_upcall(run_args->pre, PHASE_PRE_REMOVE, run_args, 0);
+ (void) zpios_upcall(run_args->pre, PHASE_PRE_REMOVE, run_args, 0);
t->start = zpios_timespec_now();
- (void)snprintf(name, 32, "%s/id_%d", run_args->pool, run_args->id);
+ (void) snprintf(name, 32, "%s/id_%d", run_args->pool, run_args->id);
if (run_args->flags & DMU_REMOVE) {
if (run_args->flags & DMU_FPP) {
for (i = 0; i < run_args->region_count; i++) {
region = &run_args->regions[i];
rc = zpios_dmu_object_free(run_args,
- region->obj.os,
- region->obj.obj);
+ region->obj.os, region->obj.obj);
if (rc)
- zpios_print(run_args->file, "Error "
- "removing object %d, %d\n",
- (int)region->obj.obj, rc);
+ zpios_print(run_args->file,
+ "Error removing object %d, %d\n",
+ (int)region->obj.obj, rc);
}
} else {
region = &run_args->regions[0];
rc = zpios_dmu_object_free(run_args,
- region->obj.os,
- region->obj.obj);
+ region->obj.os, region->obj.obj);
if (rc)
- zpios_print(run_args->file, "Error "
- "removing object %d, %d\n",
- (int)region->obj.obj, rc);
+ zpios_print(run_args->file,
+ "Error removing object %d, %d\n",
+ (int)region->obj.obj, rc);
}
}
rc = dsl_destroy_head(name);
if (rc)
zpios_print(run_args->file, "Error dsl_destroy_head"
- "(%s, ...) failed: %d\n", name, rc);
+ "(%s, ...) failed: %d\n", name, rc);
}
t->stop = zpios_timespec_now();
t->delta = zpios_timespec_sub(t->stop, t->start);
- (void)zpios_upcall(run_args->post, PHASE_POST_REMOVE, run_args, rc);
+ (void) zpios_upcall(run_args->post, PHASE_POST_REMOVE, run_args, rc);
}
static void
if (run_args->threads[i]) {
mutex_destroy(&run_args->threads[i]->lock);
kmem_free(run_args->threads[i],
- sizeof(thread_data_t));
+ sizeof (thread_data_t));
}
}
kmem_free(run_args->threads,
- sizeof(thread_data_t *) * run_args->thread_count);
+ sizeof (thread_data_t *) * run_args->thread_count);
}
for (i = 0; i < run_args->region_count; i++)
mutex_destroy(&run_args->lock_work);
mutex_destroy(&run_args->lock_ctl);
- size = run_args->region_count * sizeof(zpios_region_t);
+ size = run_args->region_count * sizeof (zpios_region_t);
- vmem_free(run_args, sizeof(*run_args) + size);
+ vmem_free(run_args, sizeof (*run_args) + size);
}
static int
zpios_print(run_args->file,
"Error in dmu_tx_assign(), %d", rc);
dmu_tx_abort(tx);
- return rc;
+ return (rc);
}
break;
}
dmu_write(os, object, offset, size, buf, tx);
dmu_tx_commit(tx);
- return 0;
+ return (0);
}
static int
zpios_dmu_read(run_args_t *run_args, objset_t *os, uint64_t object,
- uint64_t offset, uint64_t size, void *buf)
+ uint64_t offset, uint64_t size, void *buf)
{
int flags = 0;
if (run_args->flags & DMU_READ_NOPF)
flags |= DMU_READ_NO_PREFETCH;
- return dmu_read(os, object, offset, size, buf, flags);
+ return (dmu_read(os, object, offset, size, buf, flags));
}
static int
int i, rc = 0;
if (chunk_noise) {
- get_random_bytes(&random_int, sizeof(unsigned int));
+ get_random_bytes(&random_int, sizeof (unsigned int));
chunk_noise_tmp = (random_int % (chunk_noise * 2))-chunk_noise;
}
- /* It's OK to vmem_alloc() this memory because it will be copied
+ /*
+ * It's OK to vmem_alloc() this memory because it will be copied
* in to the slab and pointers to the slab copy will be setup in
* the bio when the IO is submitted. This of course is not ideal
* since we want a zero-copy IO path if possible. It would be nice
mutex_exit(&thr->lock);
while (zpios_get_work_item(run_args, &obj, &offset,
- &chunk_size, ®ion, DMU_WRITE)) {
+ &chunk_size, ®ion, DMU_WRITE)) {
if (thread_delay) {
- get_random_bytes(&random_int, sizeof(unsigned int));
+ get_random_bytes(&random_int, sizeof (unsigned int));
thread_delay_tmp = random_int % thread_delay;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(thread_delay_tmp); /* In jiffies */
t.start = zpios_timespec_now();
rc = zpios_dmu_write(run_args, obj.os, obj.obj,
- offset, chunk_size, buf);
+ offset, chunk_size, buf);
t.stop = zpios_timespec_now();
t.delta = zpios_timespec_sub(t.stop, t.start);
thr->stats.wr_data += chunk_size;
thr->stats.wr_chunks++;
thr->stats.wr_time.delta = zpios_timespec_add(
- thr->stats.wr_time.delta, t.delta);
+ thr->stats.wr_time.delta, t.delta);
mutex_exit(&thr->lock);
mutex_enter(®ion->lock);
region->stats.wr_data += chunk_size;
region->stats.wr_chunks++;
region->stats.wr_time.delta = zpios_timespec_add(
- region->stats.wr_time.delta, t.delta);
+ region->stats.wr_time.delta, t.delta);
/* First time region was accessed */
if (region->init_offset == offset)
mutex_exit(&thr->lock);
while (zpios_get_work_item(run_args, &obj, &offset,
- &chunk_size, ®ion, DMU_READ)) {
+ &chunk_size, ®ion, DMU_READ)) {
if (thread_delay) {
- get_random_bytes(&random_int, sizeof(unsigned int));
+ get_random_bytes(&random_int, sizeof (unsigned int));
thread_delay_tmp = random_int % thread_delay;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(thread_delay_tmp); /* In jiffies */
for (i = 0; i < chunk_size; i++) {
if (buf[i] != 'z') {
zpios_print(run_args->file,
- "IO verify error: %d/%d/%d\n",
- (int)obj.obj, (int)offset,
- (int)chunk_size);
+ "IO verify error: %d/%d/%d\n",
+ (int)obj.obj, (int)offset,
+ (int)chunk_size);
break;
}
}
thr->stats.rd_data += chunk_size;
thr->stats.rd_chunks++;
thr->stats.rd_time.delta = zpios_timespec_add(
- thr->stats.rd_time.delta, t.delta);
+ thr->stats.rd_time.delta, t.delta);
mutex_exit(&thr->lock);
mutex_enter(®ion->lock);
region->stats.rd_data += chunk_size;
region->stats.rd_chunks++;
region->stats.rd_time.delta = zpios_timespec_add(
- region->stats.rd_time.delta, t.delta);
+ region->stats.rd_time.delta, t.delta);
/* First time region was accessed */
if (region->init_offset == offset)
vmem_free(buf, chunk_size);
do_exit(0);
- return rc; /* Unreachable, due to do_exit() */
+ return (rc); /* Unreachable, due to do_exit() */
}
static int
zpios_time_t *tr = &(run_args->stats.rd_time);
int i, rc = 0, tc = run_args->thread_count;
- tsks = kmem_zalloc(sizeof(struct task_struct *) * tc, KM_SLEEP);
+ tsks = kmem_zalloc(sizeof (struct task_struct *) * tc, KM_SLEEP);
if (tsks == NULL) {
rc = -ENOMEM;
goto cleanup2;
}
- run_args->threads = kmem_zalloc(sizeof(thread_data_t *) * tc, KM_SLEEP);
+ run_args->threads = kmem_zalloc(sizeof (thread_data_t *)*tc, KM_SLEEP);
if (run_args->threads == NULL) {
rc = -ENOMEM;
goto cleanup;
/* Create all the needed threads which will sleep until awoken */
for (i = 0; i < tc; i++) {
- thr = kmem_zalloc(sizeof(thread_data_t), KM_SLEEP);
+ thr = kmem_zalloc(sizeof (thread_data_t), KM_SLEEP);
if (thr == NULL) {
rc = -ENOMEM;
goto taskerr;
run_args->threads[i] = thr;
tsk = kthread_create(zpios_thread_main, (void *)thr,
- "%s/%d", "zpios_io", i);
+ "%s/%d", "zpios_io", i);
if (IS_ERR(tsk)) {
rc = -EINVAL;
goto taskerr;
tt->start = zpios_timespec_now();
/* Wake up all threads for write phase */
- (void)zpios_upcall(run_args->pre, PHASE_PRE_WRITE, run_args, 0);
+ (void) zpios_upcall(run_args->pre, PHASE_PRE_WRITE, run_args, 0);
for (i = 0; i < tc; i++)
wake_up_process(tsks[i]);
tw->start = zpios_timespec_now();
wait_event(run_args->waitq, zpios_thread_done(run_args));
tw->stop = zpios_timespec_now();
- (void)zpios_upcall(run_args->post, PHASE_POST_WRITE, run_args, rc);
+ (void) zpios_upcall(run_args->post, PHASE_POST_WRITE, run_args, rc);
for (i = 0; i < tc; i++) {
thr = run_args->threads[i];
mutex_exit(&run_args->lock_ctl);
/* Wake up all threads for read phase */
- (void)zpios_upcall(run_args->pre, PHASE_PRE_READ, run_args, 0);
- for (i = 0; i < tc; i++)
+ (void) zpios_upcall(run_args->pre, PHASE_PRE_READ, run_args, 0);
+ for (i = 0; i < tc; i++)
wake_up_process(tsks[i]);
/* Wait for read phase to complete */
tr->start = zpios_timespec_now();
wait_event(run_args->waitq, zpios_thread_done(run_args));
tr->stop = zpios_timespec_now();
- (void)zpios_upcall(run_args->post, PHASE_POST_READ, run_args, rc);
+ (void) zpios_upcall(run_args->post, PHASE_POST_READ, run_args, rc);
for (i = 0; i < tc; i++) {
thr = run_args->threads[i];
tr->delta = zpios_timespec_sub(tr->stop, tr->start);
cleanup:
- kmem_free(tsks, sizeof(struct task_struct *) * tc);
+ kmem_free(tsks, sizeof (struct task_struct *) * tc);
cleanup2:
/* Returns first encountered thread error (if any) */
- return rc;
+ return (rc);
taskerr:
/* Destroy all threads that were created successfully */
static int
zpios_do_one_run(struct file *file, zpios_cmd_t *kcmd,
- int data_size, void *data)
+ int data_size, void *data)
{
run_args_t *run_args = { 0 };
zpios_stats_t *stats = (zpios_stats_t *)data;
if ((!kcmd->cmd_chunk_size) || (!kcmd->cmd_region_size) ||
(!kcmd->cmd_thread_count) || (!kcmd->cmd_region_count)) {
zpios_print(file, "Invalid chunk_size, region_size, "
- "thread_count, or region_count, %d\n", -EINVAL);
- return -EINVAL;
+ "thread_count, or region_count, %d\n", -EINVAL);
+ return (-EINVAL);
}
if (!(kcmd->cmd_flags & DMU_WRITE) ||
!(kcmd->cmd_flags & DMU_READ)) {
zpios_print(file, "Invalid flags, minimally DMU_WRITE "
- "and DMU_READ must be set, %d\n", -EINVAL);
- return -EINVAL;
+ "and DMU_READ must be set, %d\n", -EINVAL);
+ return (-EINVAL);
}
if ((kcmd->cmd_flags & (DMU_WRITE_ZC | DMU_READ_ZC)) &&
(kcmd->cmd_flags & DMU_VERIFY)) {
zpios_print(file, "Invalid flags, DMU_*_ZC incompatible "
- "with DMU_VERIFY, used for performance analysis "
- "only, %d\n", -EINVAL);
- return -EINVAL;
+ "with DMU_VERIFY, used for performance analysis "
+ "only, %d\n", -EINVAL);
+ return (-EINVAL);
}
- /* Opaque data on return contains structs of the following form:
+ /*
+ * Opaque data on return contains structs of the following form:
*
* zpios_stat_t stats[];
* stats[0] = run_args->stats;
*
* Where N is the number of threads, and M is the number of regions.
*/
- size = (sizeof(zpios_stats_t) +
- (kcmd->cmd_thread_count * sizeof(zpios_stats_t)) +
- (kcmd->cmd_region_count * sizeof(zpios_stats_t)));
+ size = (sizeof (zpios_stats_t) +
+ (kcmd->cmd_thread_count * sizeof (zpios_stats_t)) +
+ (kcmd->cmd_region_count * sizeof (zpios_stats_t)));
if (data_size < size) {
zpios_print(file, "Invalid size, command data buffer "
- "size too small, (%d < %d)\n", data_size, size);
- return -ENOSPC;
+ "size too small, (%d < %d)\n", data_size, size);
+ return (-ENOSPC);
}
rc = zpios_setup_run(&run_args, kcmd, file);
if (rc)
- return rc;
+ return (rc);
- rc = zpios_threads_run(run_args);
+ rc = zpios_threads_run(run_args);
zpios_remove_objset(run_args);
if (rc)
goto cleanup;
}
cleanup:
- zpios_cleanup_run(run_args);
+ zpios_cleanup_run(run_args);
- (void)zpios_upcall(kcmd->cmd_post, PHASE_POST_RUN, run_args, 0);
+ (void) zpios_upcall(kcmd->cmd_post, PHASE_POST_RUN, run_args, 0);
- return rc;
+ return (rc);
}
static int
zpios_info_t *info;
if (minor >= ZPIOS_MINORS)
- return -ENXIO;
+ return (-ENXIO);
- info = (zpios_info_t *)kmem_alloc(sizeof(*info), KM_SLEEP);
+ info = (zpios_info_t *)kmem_alloc(sizeof (*info), KM_SLEEP);
if (info == NULL)
- return -ENOMEM;
+ return (-ENOMEM);
spin_lock_init(&info->info_lock);
info->info_size = ZPIOS_INFO_BUFFER_SIZE;
- info->info_buffer = (char *)vmem_alloc(ZPIOS_INFO_BUFFER_SIZE,KM_SLEEP);
+ info->info_buffer =
+ (char *) vmem_alloc(ZPIOS_INFO_BUFFER_SIZE, KM_SLEEP);
if (info->info_buffer == NULL) {
- kmem_free(info, sizeof(*info));
- return -ENOMEM;
+ kmem_free(info, sizeof (*info));
+ return (-ENOMEM);
}
info->info_head = info->info_buffer;
file->private_data = (void *)info;
- return 0;
+ return (0);
}
static int
zpios_info_t *info = (zpios_info_t *)file->private_data;
if (minor >= ZPIOS_MINORS)
- return -ENXIO;
+ return (-ENXIO);
ASSERT(info);
ASSERT(info->info_buffer);
vmem_free(info->info_buffer, ZPIOS_INFO_BUFFER_SIZE);
- kmem_free(info, sizeof(*info));
+ kmem_free(info, sizeof (*info));
- return 0;
+ return (0);
}
static int
info->info_head = info->info_buffer;
spin_unlock(&info->info_lock);
- return 0;
+ return (0);
}
static int
kcfg->cfg_rc1 = info->info_size;
- if (copy_to_user((struct zpios_cfg_t __user *)arg, kcfg, sizeof(*kcfg)))
+ if (copy_to_user((struct zpios_cfg_t __user *)arg,
+ kcfg, sizeof (*kcfg)))
rc = -EFAULT;
out:
spin_unlock(&info->info_lock);
- return rc;
+ return (rc);
}
static int
zpios_cfg_t kcfg;
int rc = 0;
- if (copy_from_user(&kcfg, (zpios_cfg_t *)arg, sizeof(kcfg)))
- return -EFAULT;
+ if (copy_from_user(&kcfg, (zpios_cfg_t *)arg, sizeof (kcfg)))
+ return (-EFAULT);
if (kcfg.cfg_magic != ZPIOS_CFG_MAGIC) {
zpios_print(file, "Bad config magic 0x%x != 0x%x\n",
- kcfg.cfg_magic, ZPIOS_CFG_MAGIC);
- return -EINVAL;
+ kcfg.cfg_magic, ZPIOS_CFG_MAGIC);
+ return (-EINVAL);
}
switch (kcfg.cfg_cmd) {
case ZPIOS_CFG_BUFFER_CLEAR:
- /* cfg_arg1 - Unused
+ /*
+ * cfg_arg1 - Unused
* cfg_rc1 - Unused
*/
rc = zpios_buffer_clear(file, &kcfg, arg);
break;
case ZPIOS_CFG_BUFFER_SIZE:
- /* cfg_arg1 - 0 - query size; >0 resize
+ /*
+ * cfg_arg1 - 0 - query size; >0 resize
* cfg_rc1 - Set to current buffer size
*/
rc = zpios_buffer_size(file, &kcfg, arg);
break;
}
- return rc;
+ return (rc);
}
static int
void *data = NULL;
int rc = -EINVAL;
- kcmd = kmem_alloc(sizeof(zpios_cmd_t), KM_SLEEP);
+ kcmd = kmem_alloc(sizeof (zpios_cmd_t), KM_SLEEP);
if (kcmd == NULL) {
zpios_print(file, "Unable to kmem_alloc() %ld byte for "
- "zpios_cmd_t\n", (long int)sizeof(zpios_cmd_t));
- return -ENOMEM;
+ "zpios_cmd_t\n", (long int)sizeof (zpios_cmd_t));
+ return (-ENOMEM);
}
- rc = copy_from_user(kcmd, (zpios_cfg_t *)arg, sizeof(zpios_cmd_t));
+ rc = copy_from_user(kcmd, (zpios_cfg_t *)arg, sizeof (zpios_cmd_t));
if (rc) {
zpios_print(file, "Unable to copy command structure "
"from user to kernel memory, %d\n", rc);
if (kcmd->cmd_magic != ZPIOS_CMD_MAGIC) {
zpios_print(file, "Bad command magic 0x%x != 0x%x\n",
- kcmd->cmd_magic, ZPIOS_CFG_MAGIC);
- rc = -EINVAL;
+ kcmd->cmd_magic, ZPIOS_CFG_MAGIC);
+ rc = (-EINVAL);
goto out_cmd;
}
}
rc = copy_from_user(data, (void *)(arg + offsetof(zpios_cmd_t,
- cmd_data_str)), kcmd->cmd_data_size);
+ cmd_data_str)), kcmd->cmd_data_size);
if (rc) {
zpios_print(file, "Unable to copy data buffer "
"from user to kernel memory, %d\n", rc);
goto out_data;
rc = copy_to_user((void *)(arg + offsetof(zpios_cmd_t,
- cmd_data_str)), data, kcmd->cmd_data_size);
+ cmd_data_str)), data, kcmd->cmd_data_size);
if (rc) {
zpios_print(file, "Unable to copy data buffer "
"from kernel to user memory, %d\n", rc);
vmem_free(data, kcmd->cmd_data_size);
}
out_cmd:
- kmem_free(kcmd, sizeof(zpios_cmd_t));
+ kmem_free(kcmd, sizeof (zpios_cmd_t));
- return rc;
+ return (rc);
}
static long
zpios_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- unsigned int minor = iminor(file->f_dentry->d_inode);
+ unsigned int minor = iminor(file->f_dentry->d_inode);
int rc = 0;
/* Ignore tty ioctls */
if ((cmd & 0xffffff00) == ((int)'T') << 8)
- return -ENOTTY;
+ return (-ENOTTY);
if (minor >= ZPIOS_MINORS)
- return -ENXIO;
+ return (-ENXIO);
switch (cmd) {
case ZPIOS_CFG:
break;
}
- return rc;
+ return (rc);
}
#ifdef CONFIG_COMPAT
static long
zpios_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- return zpios_unlocked_ioctl(file, cmd, arg);
+ return (zpios_unlocked_ioctl(file, cmd, arg));
}
#endif /* CONFIG_COMPAT */
-/* I'm not sure why you would want to write in to this buffer from
+/*
+ * I'm not sure why you would want to write in to this buffer from
* user space since its principle use is to pass test status info
* back to the user space, but I don't see any reason to prevent it.
*/
static ssize_t
zpios_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+ size_t count, loff_t *ppos)
{
- unsigned int minor = iminor(file->f_dentry->d_inode);
+ unsigned int minor = iminor(file->f_dentry->d_inode);
zpios_info_t *info = (zpios_info_t *)file->private_data;
int rc = 0;
if (minor >= ZPIOS_MINORS)
- return -ENXIO;
+ return (-ENXIO);
ASSERT(info);
ASSERT(info->info_buffer);
rc = count;
out:
spin_unlock(&info->info_lock);
- return rc;
+ return (rc);
}
static ssize_t
-zpios_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
+zpios_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
- unsigned int minor = iminor(file->f_dentry->d_inode);
+ unsigned int minor = iminor(file->f_dentry->d_inode);
zpios_info_t *info = (zpios_info_t *)file->private_data;
int rc = 0;
if (minor >= ZPIOS_MINORS)
- return -ENXIO;
+ return (-ENXIO);
ASSERT(info);
ASSERT(info->info_buffer);
rc = count;
out:
spin_unlock(&info->info_lock);
- return rc;
+ return (rc);
}
static loff_t zpios_seek(struct file *file, loff_t offset, int origin)
{
- unsigned int minor = iminor(file->f_dentry->d_inode);
+ unsigned int minor = iminor(file->f_dentry->d_inode);
zpios_info_t *info = (zpios_info_t *)file->private_data;
int rc = -EINVAL;
if (minor >= ZPIOS_MINORS)
- return -ENXIO;
+ return (-ENXIO);
ASSERT(info);
ASSERT(info->info_buffer);
spin_unlock(&info->info_lock);
- return rc;
+ return (rc);
}
static struct cdev zpios_cdev;
}
zpios_device = spl_device_create(zpios_class, NULL,
- dev, NULL, ZPIOS_NAME);
- return 0;
+ dev, NULL, ZPIOS_NAME);
+
+ return (0);
error:
printk(KERN_ERR "ZPIOS: Error registering zpios device, %d\n", rc);
- return rc;
+ return (rc);
}
static int
cdev_del(&zpios_cdev);
unregister_chrdev_region(dev, ZPIOS_MINORS);
- return 0;
+ return (0);
}
spl_module_init(zpios_init);