Skip to content

Commit

Permalink
Undo c89 workarounds to match with upstream
Browse files Browse the repository at this point in the history
With PR 5756 the zfs module now supports c99 and the
remaining past c89 workarounds can be undone.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Don Brady <don.brady@delphix.com>
Closes #6816
  • Loading branch information
don-brady authored and behlendorf committed Nov 4, 2017
1 parent df1f129 commit 1c27024
Show file tree
Hide file tree
Showing 48 changed files with 424 additions and 764 deletions.
3 changes: 1 addition & 2 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ _NOTE(CONSTCOND) } while (0)
{ "zero", "single", "double", "triple" }; \
int len = 0; \
int copies = 0; \
int d; \
\
if (bp == NULL) { \
len += func(buf + len, size - len, "<NULL>"); \
Expand All @@ -662,7 +661,7 @@ _NOTE(CONSTCOND) } while (0)
(u_longlong_t)BPE_GET_PSIZE(bp), \
(u_longlong_t)bp->blk_birth); \
} else { \
for (d = 0; d < BP_GET_NDVAS(bp); d++) { \
for (int d = 0; d < BP_GET_NDVAS(bp); d++) { \
const dva_t *dva = &bp->blk_dva[d]; \
if (DVA_IS_VALID(dva)) \
copies++; \
Expand Down
16 changes: 4 additions & 12 deletions module/zcommon/zfeature_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,21 @@ zfeature_is_valid_guid(const char *name)
boolean_t
zfeature_is_supported(const char *guid)
{
spa_feature_t i;

if (zfeature_checks_disable)
return (B_TRUE);

for (i = 0; i < SPA_FEATURES; i++) {
for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
zfeature_info_t *feature = &spa_feature_table[i];
if (strcmp(guid, feature->fi_guid) == 0)
return (B_TRUE);
}

return (B_FALSE);
}

int
zfeature_lookup_name(const char *name, spa_feature_t *res)
{
spa_feature_t i;

for (i = 0; i < SPA_FEATURES; i++) {
for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
zfeature_info_t *feature = &spa_feature_table[i];
if (strcmp(name, feature->fi_uname) == 0) {
if (res != NULL)
Expand All @@ -126,9 +121,8 @@ boolean_t
zfeature_depends_on(spa_feature_t fid, spa_feature_t check)
{
zfeature_info_t *feature = &spa_feature_table[fid];
int i;

for (i = 0; feature->fi_depends[i] != SPA_FEATURE_NONE; i++) {
for (int i = 0; feature->fi_depends[i] != SPA_FEATURE_NONE; i++) {
if (feature->fi_depends[i] == check)
return (B_TRUE);
}
Expand All @@ -138,9 +132,7 @@ zfeature_depends_on(spa_feature_t fid, spa_feature_t check)
static boolean_t
deps_contains_feature(const spa_feature_t *deps, const spa_feature_t feature)
{
int i;

for (i = 0; deps[i] != SPA_FEATURE_NONE; i++)
for (int i = 0; deps[i] != SPA_FEATURE_NONE; i++)
if (deps[i] == feature)
return (B_TRUE);

Expand Down
5 changes: 3 additions & 2 deletions module/zcommon/zfs_namecheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ permset_namecheck(const char *path, namecheck_err_t *why, char *what)
int
entity_namecheck(const char *path, namecheck_err_t *why, char *what)
{
const char *start, *end, *loc;
const char *start, *end;
int found_delim;

/*
* Make sure the name is not too long.
*/

if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) {
if (why)
*why = NAME_ERR_TOOLONG;
Expand Down Expand Up @@ -178,7 +179,7 @@ entity_namecheck(const char *path, namecheck_err_t *why, char *what)
}

/* Validate the contents of this component */
for (loc = start; loc != end; loc++) {
for (const char *loc = start; loc != end; loc++) {
if (!valid_char(*loc) && *loc != '%') {
if (why) {
*why = NAME_ERR_INVALCHAR;
Expand Down
4 changes: 2 additions & 2 deletions module/zcommon/zprop_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int
zprop_iter_common(zprop_func func, void *cb, boolean_t show_all,
boolean_t ordered, zfs_type_t type)
{
int i, j, num_props, size, prop;
int i, num_props, size, prop;
zprop_desc_t *prop_tbl;
zprop_desc_t **order;

Expand All @@ -181,7 +181,7 @@ zprop_iter_common(zprop_func func, void *cb, boolean_t show_all,
return (ZPROP_CONT);
#endif

for (j = 0; j < num_props; j++)
for (int j = 0; j < num_props; j++)
order[j] = &prop_tbl[j];

if (ordered) {
Expand Down
14 changes: 5 additions & 9 deletions module/zfs/abd.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,12 @@ abd_free_struct(abd_t *abd)
abd_t *
abd_alloc(size_t size, boolean_t is_metadata)
{
abd_t *abd;

if (!zfs_abd_scatter_enabled || size <= PAGESIZE)
return (abd_alloc_linear(size, is_metadata));

VERIFY3U(size, <=, SPA_MAXBLOCKSIZE);

abd = abd_alloc_struct();
abd_t *abd = abd_alloc_struct();
abd->abd_flags = ABD_FLAG_OWNER;
abd_alloc_pages(abd, size);

Expand Down Expand Up @@ -1108,10 +1106,9 @@ abd_iterate_func(abd_t *abd, size_t off, size_t size,
abd_iter_advance(&aiter, off);

while (size > 0) {
size_t len;
abd_iter_map(&aiter);

len = MIN(aiter.iter_mapsize, size);
size_t len = MIN(aiter.iter_mapsize, size);
ASSERT3U(len, >, 0);

ret = func(aiter.iter_mapaddr, len, private);
Expand Down Expand Up @@ -1242,13 +1239,12 @@ abd_iterate_func2(abd_t *dabd, abd_t *sabd, size_t doff, size_t soff,
abd_iter_advance(&saiter, soff);

while (size > 0) {
size_t dlen, slen, len;
abd_iter_map(&daiter);
abd_iter_map(&saiter);

dlen = MIN(daiter.iter_mapsize, size);
slen = MIN(saiter.iter_mapsize, size);
len = MIN(dlen, slen);
size_t dlen = MIN(daiter.iter_mapsize, size);
size_t slen = MIN(saiter.iter_mapsize, size);
size_t len = MIN(dlen, slen);
ASSERT(dlen > 0 || slen > 0);

ret = func(daiter.iter_mapaddr, saiter.iter_mapaddr, len,
Expand Down
44 changes: 19 additions & 25 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,6 @@ static void
arc_evictable_space_increment(arc_buf_hdr_t *hdr, arc_state_t *state)
{
arc_buf_contents_t type = arc_buf_type(hdr);
arc_buf_t *buf;

ASSERT(HDR_HAS_L1HDR(hdr));

Expand All @@ -2290,7 +2289,8 @@ arc_evictable_space_increment(arc_buf_hdr_t *hdr, arc_state_t *state)
HDR_GET_PSIZE(hdr), hdr);
}

for (buf = hdr->b_l1hdr.b_buf; buf != NULL; buf = buf->b_next) {
for (arc_buf_t *buf = hdr->b_l1hdr.b_buf; buf != NULL;
buf = buf->b_next) {
if (arc_buf_is_shared(buf))
continue;
(void) refcount_add_many(&state->arcs_esize[type],
Expand All @@ -2307,7 +2307,6 @@ static void
arc_evictable_space_decrement(arc_buf_hdr_t *hdr, arc_state_t *state)
{
arc_buf_contents_t type = arc_buf_type(hdr);
arc_buf_t *buf;

ASSERT(HDR_HAS_L1HDR(hdr));

Expand All @@ -2331,7 +2330,8 @@ arc_evictable_space_decrement(arc_buf_hdr_t *hdr, arc_state_t *state)
HDR_GET_PSIZE(hdr), hdr);
}

for (buf = hdr->b_l1hdr.b_buf; buf != NULL; buf = buf->b_next) {
for (arc_buf_t *buf = hdr->b_l1hdr.b_buf; buf != NULL;
buf = buf->b_next) {
if (arc_buf_is_shared(buf))
continue;
(void) refcount_remove_many(&state->arcs_esize[type],
Expand Down Expand Up @@ -2547,15 +2547,14 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t *hdr,
ASSERT3P(hdr->b_l1hdr.b_pabd, ==, NULL);
ASSERT(!HDR_HAS_RABD(hdr));
} else {
arc_buf_t *buf;
uint32_t buffers = 0;

/*
* Each individual buffer holds a unique reference,
* thus we must remove each of these references one
* at a time.
*/
for (buf = hdr->b_l1hdr.b_buf; buf != NULL;
for (arc_buf_t *buf = hdr->b_l1hdr.b_buf; buf != NULL;
buf = buf->b_next) {
ASSERT3U(bufcnt, !=, 0);
buffers++;
Expand Down Expand Up @@ -2605,15 +2604,14 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t *hdr,
(void) refcount_remove_many(&old_state->arcs_size,
HDR_GET_LSIZE(hdr), hdr);
} else {
arc_buf_t *buf;
uint32_t buffers = 0;

/*
* Each individual buffer holds a unique reference,
* thus we must remove each of these references one
* at a time.
*/
for (buf = hdr->b_l1hdr.b_buf; buf != NULL;
for (arc_buf_t *buf = hdr->b_l1hdr.b_buf; buf != NULL;
buf = buf->b_next) {
ASSERT3U(bufcnt, !=, 0);
buffers++;
Expand Down Expand Up @@ -3344,10 +3342,11 @@ arc_hdr_alloc(uint64_t spa, int32_t psize, int32_t lsize,
static arc_buf_hdr_t *
arc_hdr_realloc(arc_buf_hdr_t *hdr, kmem_cache_t *old, kmem_cache_t *new)
{
ASSERT(HDR_HAS_L2HDR(hdr));

arc_buf_hdr_t *nhdr;
l2arc_dev_t *dev = hdr->b_l2hdr.b_dev;

ASSERT(HDR_HAS_L2HDR(hdr));
ASSERT((old == hdr_full_cache && new == hdr_l2only_cache) ||
(old == hdr_l2only_cache && new == hdr_full_cache));

Expand Down Expand Up @@ -4021,7 +4020,6 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
multilist_t *ml = state->arcs_list[type];
int num_sublists;
arc_buf_hdr_t **markers;
int i;

IMPLY(bytes < 0, bytes == ARC_EVICT_ALL);

Expand All @@ -4035,7 +4033,7 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
* than starting from the tail each time.
*/
markers = kmem_zalloc(sizeof (*markers) * num_sublists, KM_SLEEP);
for (i = 0; i < num_sublists; i++) {
for (int i = 0; i < num_sublists; i++) {
multilist_sublist_t *mls;

markers[i] = kmem_cache_alloc(hdr_full_cache, KM_SLEEP);
Expand Down Expand Up @@ -4076,7 +4074,7 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
* (e.g. index 0) would cause evictions to favor certain
* sublists over others.
*/
for (i = 0; i < num_sublists; i++) {
for (int i = 0; i < num_sublists; i++) {
uint64_t bytes_remaining;
uint64_t bytes_evicted;

Expand Down Expand Up @@ -4122,7 +4120,7 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
}
}

for (i = 0; i < num_sublists; i++) {
for (int i = 0; i < num_sublists; i++) {
multilist_sublist_t *mls = multilist_sublist_lock(ml, i);
multilist_sublist_remove(mls, markers[i]);
multilist_sublist_unlock(mls);
Expand Down Expand Up @@ -4947,7 +4945,6 @@ arc_reclaim_thread(void *unused)

mutex_enter(&arc_reclaim_lock);
while (!arc_reclaim_thread_exit) {
int64_t to_free;
uint64_t evicted = 0;
uint64_t need_free = arc_need_free;
arc_tuning_update();
Expand Down Expand Up @@ -4996,7 +4993,8 @@ arc_reclaim_thread(void *unused)
*/
free_memory = arc_available_memory();

to_free = (arc_c >> arc_shrink_shift) - free_memory;
int64_t to_free =
(arc_c >> arc_shrink_shift) - free_memory;
if (to_free > 0) {
#ifdef _KERNEL
to_free = MAX(to_free, need_free);
Expand Down Expand Up @@ -5665,15 +5663,14 @@ arc_read_done(zio_t *zio)
* read.
*/
if (HDR_IN_HASH_TABLE(hdr)) {
arc_buf_hdr_t *found;

ASSERT3U(hdr->b_birth, ==, BP_PHYSICAL_BIRTH(zio->io_bp));
ASSERT3U(hdr->b_dva.dva_word[0], ==,
BP_IDENTITY(zio->io_bp)->dva_word[0]);
ASSERT3U(hdr->b_dva.dva_word[1], ==,
BP_IDENTITY(zio->io_bp)->dva_word[1]);

found = buf_hash_find(hdr->b_spa, zio->io_bp, &hash_lock);
arc_buf_hdr_t *found = buf_hash_find(hdr->b_spa, zio->io_bp,
&hash_lock);

ASSERT((found == hdr &&
DVA_EQUAL(&hdr->b_dva, BP_IDENTITY(zio->io_bp))) ||
Expand Down Expand Up @@ -6372,8 +6369,6 @@ arc_freed(spa_t *spa, const blkptr_t *bp)
void
arc_release(arc_buf_t *buf, void *tag)
{
kmutex_t *hash_lock;
arc_state_t *state;
arc_buf_hdr_t *hdr = buf->b_hdr;

/*
Expand Down Expand Up @@ -6414,15 +6409,15 @@ arc_release(arc_buf_t *buf, void *tag)
return;
}

hash_lock = HDR_LOCK(hdr);
kmutex_t *hash_lock = HDR_LOCK(hdr);
mutex_enter(hash_lock);

/*
* This assignment is only valid as long as the hash_lock is
* held, we must be careful not to reference state or the
* b_state field after dropping the lock.
*/
state = hdr->b_l1hdr.b_state;
arc_state_t *state = hdr->b_l1hdr.b_state;
ASSERT3P(hash_lock, ==, HDR_LOCK(hdr));
ASSERT3P(state, !=, arc_anon);

Expand Down Expand Up @@ -6622,7 +6617,6 @@ arc_write_ready(zio_t *zio)
arc_buf_hdr_t *hdr = buf->b_hdr;
blkptr_t *bp = zio->io_bp;
uint64_t psize = BP_IS_HOLE(bp) ? 0 : BP_GET_PSIZE(bp);
enum zio_compress compress;
fstrans_cookie_t cookie = spl_fstrans_mark();

ASSERT(HDR_HAS_L1HDR(hdr));
Expand Down Expand Up @@ -6689,6 +6683,7 @@ arc_write_ready(zio_t *zio)
/* this must be done after the buffer flags are adjusted */
arc_cksum_compute(buf);

enum zio_compress compress;
if (BP_IS_HOLE(bp) || BP_IS_EMBEDDED(bp)) {
compress = ZIO_COMPRESS_OFF;
} else {
Expand Down Expand Up @@ -8459,7 +8454,6 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
l2arc_write_callback_t *cb;
zio_t *pio, *wzio;
uint64_t guid = spa_load_guid(spa);
int try;

ASSERT3P(dev->l2ad_vdev, !=, NULL);

Expand All @@ -8472,7 +8466,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
/*
* Copy buffers for L2ARC writing.
*/
for (try = 0; try < L2ARC_FEED_TYPES; try++) {
for (int try = 0; try < L2ARC_FEED_TYPES; try++) {
multilist_sublist_t *mls = l2arc_sublist_lock(try);
uint64_t passed_sz = 0;

Expand Down
Loading

0 comments on commit 1c27024

Please sign in to comment.