static struct grant_thread_data client_gtd;
static int osc_shrink_grant_interpret(const struct lu_env *env,
- struct ptlrpc_request *req,
- void *aa, int rc)
+ struct ptlrpc_request *req,
+ void *aa, int rc)
{
- struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
- struct obdo *oa = ((struct osc_grant_args *)aa)->aa_oa;
- struct ost_body *body;
+ struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
+ struct obdo *oa = ((struct osc_grant_args *)aa)->aa_oa;
+ struct ost_body *body;
- if (rc != 0) {
- __osc_update_grant(cli, oa->o_grant);
- GOTO(out, rc);
- }
+ if (rc != 0) {
+ __osc_update_grant(cli, oa->o_grant);
+ GOTO(out, rc);
+ }
- body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- LASSERT(body);
- osc_update_grant(cli, body);
+ body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
+ LASSERT(body);
+ osc_update_grant(cli, body);
out:
- OBDO_FREE(oa);
- return rc;
+ OBD_SLAB_FREE_PTR(oa, osc_obdo_kmem);
+ return rc;
}
static void osc_shrink_grant_local(struct client_obd *cli, struct obdo *oa)
osc_announce_cached(cli, &body->oa, 0);
spin_lock(&cli->cl_loi_list_lock);
+ if (target_bytes >= cli->cl_avail_grant) {
+ /* available grant has changed since target calculation */
+ spin_unlock(&cli->cl_loi_list_lock);
+ GOTO(out_free, rc = 0);
+ }
body->oa.o_grant = cli->cl_avail_grant - target_bytes;
cli->cl_avail_grant = target_bytes;
spin_unlock(&cli->cl_loi_list_lock);
sizeof(*body), body, NULL);
if (rc != 0)
__osc_update_grant(cli, body->oa.o_grant);
+out_free:
OBD_FREE_PTR(body);
RETURN(rc);
}
int sector_size,
u32 *check_sum)
{
- struct cfs_crypto_hash_desc *hdesc;
+ struct ahash_request *req;
/* Used Adler as the default checksum type on top of DIF tags */
unsigned char cfs_alg = cksum_obd2cfs(OBD_CKSUM_T10_TOP);
struct page *__page;
if (__page == NULL)
return -ENOMEM;
- hdesc = cfs_crypto_hash_init(cfs_alg, NULL, 0);
- if (IS_ERR(hdesc)) {
- rc = PTR_ERR(hdesc);
+ req = cfs_crypto_hash_init(cfs_alg, NULL, 0);
+ if (IS_ERR(req)) {
+ rc = PTR_ERR(req);
CERROR("%s: unable to initialize checksum hash %s: rc = %d\n",
obd_name, cfs_crypto_hash_name(cfs_alg), rc);
GOTO(out, rc);
used_number += used;
if (used_number == guard_number) {
- cfs_crypto_hash_update_page(hdesc, __page, 0,
+ cfs_crypto_hash_update_page(req, __page, 0,
used_number * sizeof(*guard_start));
used_number = 0;
}
GOTO(out, rc);
if (used_number != 0)
- cfs_crypto_hash_update_page(hdesc, __page, 0,
+ cfs_crypto_hash_update_page(req, __page, 0,
used_number * sizeof(*guard_start));
bufsize = sizeof(cksum);
- cfs_crypto_hash_final(hdesc, (unsigned char *)&cksum, &bufsize);
+ cfs_crypto_hash_final(req, (unsigned char *)&cksum, &bufsize);
/* For sending we only compute the wrong checksum instead
* of corrupting the data so it is still correct on a redo */
u32 *cksum)
{
int i = 0;
- struct cfs_crypto_hash_desc *hdesc;
+ struct ahash_request *req;
unsigned int bufsize;
unsigned char cfs_alg = cksum_obd2cfs(cksum_type);
LASSERT(pg_count > 0);
- hdesc = cfs_crypto_hash_init(cfs_alg, NULL, 0);
- if (IS_ERR(hdesc)) {
+ req = cfs_crypto_hash_init(cfs_alg, NULL, 0);
+ if (IS_ERR(req)) {
CERROR("Unable to initialize checksum hash %s\n",
cfs_crypto_hash_name(cfs_alg));
- return PTR_ERR(hdesc);
+ return PTR_ERR(req);
}
while (nob > 0 && pg_count > 0) {
memcpy(ptr + off, "bad1", min_t(typeof(nob), 4, nob));
kunmap(pga[i]->pg);
}
- cfs_crypto_hash_update_page(hdesc, pga[i]->pg,
+ cfs_crypto_hash_update_page(req, pga[i]->pg,
pga[i]->off & ~PAGE_MASK,
count);
LL_CDEBUG_PAGE(D_PAGE, pga[i]->pg, "off %d\n",
}
bufsize = sizeof(*cksum);
- cfs_crypto_hash_final(hdesc, (unsigned char *)cksum, &bufsize);
+ cfs_crypto_hash_final(req, (unsigned char *)cksum, &bufsize);
/* For sending we only compute the wrong checksum instead
* of corrupting the data so it is still correct on a redo */
for (i = 0; i < page_count; i++)
short_io_size += pga[i]->count;
- /* Check if we can do a short io. */
- if (!(short_io_size <= cli->cl_short_io_bytes && niocount == 1 &&
- imp_connect_shortio(cli->cl_import)))
+ /* Check if read/write is small enough to be a short io. */
+ if (short_io_size > cli->cl_max_short_io_bytes || niocount > 1 ||
+ !imp_connect_shortio(cli->cl_import))
short_io_size = 0;
req_capsule_set_size(pill, &RMF_SHORT_IO, RCL_CLIENT,
cl_object_attr_update(env, obj, attr, valid);
cl_object_attr_unlock(obj);
}
- OBDO_FREE(aa->aa_oa);
+ OBD_SLAB_FREE_PTR(aa->aa_oa, osc_obdo_kmem);
if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE && rc == 0)
osc_inc_unstable_pages(req);
if (pga == NULL)
GOTO(out, rc = -ENOMEM);
- OBDO_ALLOC(oa);
+ OBD_SLAB_ALLOC_PTR_GFP(oa, osc_obdo_kmem, GFP_NOFS);
if (oa == NULL)
GOTO(out, rc = -ENOMEM);
LASSERT(req == NULL);
if (oa)
- OBDO_FREE(oa);
+ OBD_SLAB_FREE_PTR(oa, osc_obdo_kmem);
if (pga)
OBD_FREE(pga, sizeof(*pga) * page_count);
/* this should happen rarely and is pretty bad, it makes the
CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
aa = ptlrpc_req_async_args(req);
- OBDO_ALLOC(oa);
+ OBD_SLAB_ALLOC_PTR_GFP(oa, osc_obdo_kmem, GFP_NOFS);
if (!oa) {
ptlrpc_req_finished(req);
RETURN(-ENOMEM);