Commit 490e0e89 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: osc: remove final uses of the GOTO macro

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier lbl;
identifier rc;
constant c;
@@

- GOTO(lbl,\(rc\|c\));
+ goto lbl;

@@
identifier lbl;
expression rc;
@@

- GOTO(lbl,rc);
+ rc;
+ goto lbl;
// </smpl>

In one case (OES_INV), consecutive gotos were factorized and a break was
removed.
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 337832b7
...@@ -178,76 +178,113 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, ...@@ -178,76 +178,113 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
int page_count; int page_count;
int rc = 0; int rc = 0;
if (!osc_object_is_locked(obj)) if (!osc_object_is_locked(obj)) {
GOTO(out, rc = 9); rc = 9;
goto out;
}
if (ext->oe_state >= OES_STATE_MAX) if (ext->oe_state >= OES_STATE_MAX) {
GOTO(out, rc = 10); rc = 10;
goto out;
}
if (atomic_read(&ext->oe_refc) <= 0) if (atomic_read(&ext->oe_refc) <= 0) {
GOTO(out, rc = 20); rc = 20;
goto out;
}
if (atomic_read(&ext->oe_refc) < atomic_read(&ext->oe_users)) if (atomic_read(&ext->oe_refc) < atomic_read(&ext->oe_users)) {
GOTO(out, rc = 30); rc = 30;
goto out;
}
switch (ext->oe_state) { switch (ext->oe_state) {
case OES_INV: case OES_INV:
if (ext->oe_nr_pages > 0 || !list_empty(&ext->oe_pages)) if (ext->oe_nr_pages > 0 || !list_empty(&ext->oe_pages))
GOTO(out, rc = 35); rc = 35;
GOTO(out, rc = 0); else
break; rc = 0;
goto out;
case OES_ACTIVE: case OES_ACTIVE:
if (atomic_read(&ext->oe_users) == 0) if (atomic_read(&ext->oe_users) == 0) {
GOTO(out, rc = 40); rc = 40;
if (ext->oe_hp) goto out;
GOTO(out, rc = 50); }
if (ext->oe_fsync_wait && !ext->oe_urgent) if (ext->oe_hp) {
GOTO(out, rc = 55); rc = 50;
goto out;
}
if (ext->oe_fsync_wait && !ext->oe_urgent) {
rc = 55;
goto out;
}
break; break;
case OES_CACHE: case OES_CACHE:
if (ext->oe_grants == 0) if (ext->oe_grants == 0) {
GOTO(out, rc = 60); rc = 60;
if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp) goto out;
GOTO(out, rc = 65); }
if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp) {
rc = 65;
goto out;
}
default: default:
if (atomic_read(&ext->oe_users) > 0) if (atomic_read(&ext->oe_users) > 0) {
GOTO(out, rc = 70); rc = 70;
goto out;
}
} }
if (ext->oe_max_end < ext->oe_end || ext->oe_end < ext->oe_start) if (ext->oe_max_end < ext->oe_end || ext->oe_end < ext->oe_start) {
GOTO(out, rc = 80); rc = 80;
goto out;
}
if (ext->oe_osclock == NULL && ext->oe_grants > 0) if (ext->oe_osclock == NULL && ext->oe_grants > 0) {
GOTO(out, rc = 90); rc = 90;
goto out;
}
if (ext->oe_osclock) { if (ext->oe_osclock) {
struct cl_lock_descr *descr; struct cl_lock_descr *descr;
descr = &ext->oe_osclock->cll_descr; descr = &ext->oe_osclock->cll_descr;
if (!(descr->cld_start <= ext->oe_start && if (!(descr->cld_start <= ext->oe_start &&
descr->cld_end >= ext->oe_max_end)) descr->cld_end >= ext->oe_max_end)) {
GOTO(out, rc = 100); rc = 100;
goto out;
}
} }
if (ext->oe_nr_pages > ext->oe_mppr) if (ext->oe_nr_pages > ext->oe_mppr) {
GOTO(out, rc = 105); rc = 105;
goto out;
}
/* Do not verify page list if extent is in RPC. This is because an /* Do not verify page list if extent is in RPC. This is because an
* in-RPC extent is supposed to be exclusively accessible w/o lock. */ * in-RPC extent is supposed to be exclusively accessible w/o lock. */
if (ext->oe_state > OES_CACHE) if (ext->oe_state > OES_CACHE) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
if (!extent_debug) if (!extent_debug) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
page_count = 0; page_count = 0;
list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) { list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) {
pgoff_t index = oap2cl_page(oap)->cp_index; pgoff_t index = oap2cl_page(oap)->cp_index;
++page_count; ++page_count;
if (index > ext->oe_end || index < ext->oe_start) if (index > ext->oe_end || index < ext->oe_start) {
GOTO(out, rc = 110); rc = 110;
goto out;
}
}
if (page_count != ext->oe_nr_pages) {
rc = 120;
goto out;
} }
if (page_count != ext->oe_nr_pages)
GOTO(out, rc = 120);
out: out:
if (rc != 0) if (rc != 0)
...@@ -774,8 +811,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, ...@@ -774,8 +811,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env,
rc = osc_extent_wait(env, conflict, OES_INV); rc = osc_extent_wait(env, conflict, OES_INV);
osc_extent_put(env, conflict); osc_extent_put(env, conflict);
conflict = NULL; conflict = NULL;
if (rc < 0) if (rc < 0) {
GOTO(out, found = ERR_PTR(rc)); found = ERR_PTR(rc);
goto out;
}
goto restart; goto restart;
} }
...@@ -932,7 +971,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, ...@@ -932,7 +971,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
io->ci_obj = cl_object_top(osc2cl(obj)); io->ci_obj = cl_object_top(osc2cl(obj));
rc = cl_io_init(env, io, CIT_MISC, io->ci_obj); rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
if (rc < 0) if (rc < 0)
GOTO(out, rc); goto out;
/* discard all pages with index greater then trunc_index */ /* discard all pages with index greater then trunc_index */
list_for_each_entry_safe(oap, tmp, &ext->oe_pages, list_for_each_entry_safe(oap, tmp, &ext->oe_pages,
...@@ -1112,21 +1151,27 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) ...@@ -1112,21 +1151,27 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants)
osc_object_lock(obj); osc_object_lock(obj);
LASSERT(sanity_check_nolock(ext) == 0); LASSERT(sanity_check_nolock(ext) == 0);
end_chunk = ext->oe_end >> ppc_bits; end_chunk = ext->oe_end >> ppc_bits;
if (chunk > end_chunk + 1) if (chunk > end_chunk + 1) {
GOTO(out, rc = -ERANGE); rc = -ERANGE;
goto out;
}
if (end_chunk >= chunk) if (end_chunk >= chunk) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
LASSERT(end_chunk + 1 == chunk); LASSERT(end_chunk + 1 == chunk);
/* try to expand this extent to cover @index */ /* try to expand this extent to cover @index */
end_index = min(ext->oe_max_end, ((chunk + 1) << ppc_bits) - 1); end_index = min(ext->oe_max_end, ((chunk + 1) << ppc_bits) - 1);
next = next_extent(ext); next = next_extent(ext);
if (next != NULL && next->oe_start <= end_index) if (next != NULL && next->oe_start <= end_index) {
/* complex mode - overlapped with the next extent, /* complex mode - overlapped with the next extent,
* this case will be handled by osc_extent_find() */ * this case will be handled by osc_extent_find() */
GOTO(out, rc = -EAGAIN); rc = -EAGAIN;
goto out;
}
ext->oe_end = end_index; ext->oe_end = end_index;
ext->oe_grants += chunksize; ext->oe_grants += chunksize;
...@@ -1495,12 +1540,16 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, ...@@ -1495,12 +1540,16 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
* of queued writes and create a discontiguous rpc stream */ * of queued writes and create a discontiguous rpc stream */
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_NO_GRANT) || if (OBD_FAIL_CHECK(OBD_FAIL_OSC_NO_GRANT) ||
cli->cl_dirty_max < PAGE_CACHE_SIZE || cli->cl_dirty_max < PAGE_CACHE_SIZE ||
cli->cl_ar.ar_force_sync || loi->loi_ar.ar_force_sync) cli->cl_ar.ar_force_sync || loi->loi_ar.ar_force_sync) {
GOTO(out, rc = -EDQUOT); rc = -EDQUOT;
goto out;
}
/* Hopefully normal case - cache space and write credits available */ /* Hopefully normal case - cache space and write credits available */
if (osc_enter_cache_try(cli, oap, bytes, 0)) if (osc_enter_cache_try(cli, oap, bytes, 0)) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
/* We can get here for two reasons: too many dirty pages in cache, or /* We can get here for two reasons: too many dirty pages in cache, or
* run out of grants. In both cases we should write dirty pages out. * run out of grants. In both cases we should write dirty pages out.
...@@ -1528,16 +1577,18 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, ...@@ -1528,16 +1577,18 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
/* l_wait_event is interrupted by signal */ /* l_wait_event is interrupted by signal */
if (rc < 0) { if (rc < 0) {
list_del_init(&ocw.ocw_entry); list_del_init(&ocw.ocw_entry);
GOTO(out, rc); goto out;
} }
LASSERT(list_empty(&ocw.ocw_entry)); LASSERT(list_empty(&ocw.ocw_entry));
rc = ocw.ocw_rc; rc = ocw.ocw_rc;
if (rc != -EDQUOT) if (rc != -EDQUOT)
GOTO(out, rc); goto out;
if (osc_enter_cache_try(cli, oap, bytes, 0)) if (osc_enter_cache_try(cli, oap, bytes, 0)) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
} }
out: out:
client_obd_list_unlock(&cli->cl_loi_list_lock); client_obd_list_unlock(&cli->cl_loi_list_lock);
...@@ -2399,14 +2450,15 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, ...@@ -2399,14 +2450,15 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
* one making the extent active, we could deadlock waiting for * one making the extent active, we could deadlock waiting for
* the page writeback to clear but it won't because the extent * the page writeback to clear but it won't because the extent
* is active and won't be written out. */ * is active and won't be written out. */
GOTO(out, rc = -EAGAIN); rc = -EAGAIN;
goto out;
default: default:
break; break;
} }
rc = cl_page_prep(env, io, cl_page_top(cp), CRT_WRITE); rc = cl_page_prep(env, io, cl_page_top(cp), CRT_WRITE);
if (rc) if (rc)
GOTO(out, rc); goto out;
spin_lock(&oap->oap_lock); spin_lock(&oap->oap_lock);
oap->oap_async_flags |= ASYNC_READY|ASYNC_URGENT; oap->oap_async_flags |= ASYNC_READY|ASYNC_URGENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment