* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
{
if (ofd_obd(ofd)->obd_self_export == exp)
/* Grant enough space to handle a big precreate request */
- return OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace;
+ return OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace / 2;
if (ofd_grant_compat(exp, ofd))
/* Try to grant enough space to send a full-size RPC */
rc = ofd_statfs_internal(env, ofd, osfs, max_age, from_cache);
if (unlikely(rc)) {
- *from_cache = 0;
+ if (from_cache)
+ *from_cache = 0;
return;
}
obd_size unstable;
ENTRY;
- LASSERT_SPIN_LOCKED(&ofd->ofd_grant_lock);
+ assert_spin_locked(&ofd->ofd_grant_lock);
spin_lock(&ofd->ofd_osfs_lock);
/* get available space from cached statfs data */
D_ERROR : D_CACHE;
CDEBUG_LIMIT(mask, "%s: cli %s/%p left "LPU64" < tot_grant "
- LPU64" unstable "LPU64" pending "LPU64"\n",
+ LPU64" unstable "LPU64" pending "LPU64" "
+ "dirty "LPU64"\n",
obd->obd_name, exp->exp_client_uuid.uuid, exp,
left, tot_granted, unstable,
- ofd->ofd_tot_pending);
+ ofd->ofd_tot_pending, ofd->ofd_tot_dirty);
RETURN(0);
}
long dirty, dropped, grant_chunk;
ENTRY;
- LASSERT_SPIN_LOCKED(&ofd->ofd_grant_lock);
+ assert_spin_locked(&ofd->ofd_grant_lock);
if ((oa->o_valid & (OBD_MD_FLBLOCKS|OBD_MD_FLGRANT)) !=
(OBD_MD_FLBLOCKS|OBD_MD_FLGRANT)) {
struct obd_device *obd = exp->exp_obd;
long grant_shrink;
- LASSERT_SPIN_LOCKED(&ofd->ofd_grant_lock);
+ assert_spin_locked(&ofd->ofd_grant_lock);
LASSERT(exp);
if (left_space >= ofd->ofd_tot_granted_clients *
OFD_GRANT_SHRINK_LIMIT(exp))
ENTRY;
- LASSERT_SPIN_LOCKED(&ofd->ofd_grant_lock);
+ assert_spin_locked(&ofd->ofd_grant_lock);
if ((oa->o_valid & OBD_MD_FLFLAGS) &&
(oa->o_flags & OBD_FL_RECOV_RESEND)) {
/* client not supporting OBD_CONNECT_GRANT_PARAM works with a 4KB block
* size while the reality is different */
- curgrant = ofd_grant_from_cli(exp, ofd, curgrant);
- want = ofd_grant_from_cli(exp, ofd, want);
+ curgrant = ofd_grant_from_cli(exp, ofd, curgrant);
+ want = ofd_grant_from_cli(exp, ofd, want);
grant_chunk = ofd_grant_chunk(exp, ofd);
/* Grant some fraction of the client's requested grant space so that
* one chunk */
left >>= 3;
grant = min(want, left);
- /* align grant on block size */
- grant &= ~((1ULL << ofd->ofd_blockbits) - 1);
+ /* round grant upt to the next block size */
+ grant = (grant + (1 << ofd->ofd_blockbits) - 1) &
+ ~((1ULL << ofd->ofd_blockbits) - 1);
if (!grant)
RETURN(0);
struct filter_export_data *fed = &exp->exp_filter_data;
obd_size left = 0;
unsigned long wanted;
-
ENTRY;
info->fti_used = 0;
(ofd->ofd_osfs.os_blocks >> 10)) {
spin_unlock(&ofd->ofd_grant_lock);
CDEBUG(D_RPCTRACE, "%s: not enough space for create "LPU64"\n",
- ofd_obd(ofd)->obd_name,
+ ofd_name(ofd),
ofd->ofd_osfs.os_bavail * ofd->ofd_osfs.os_blocks);
RETURN(-ENOSPC);
}
fed->fed_pending += info->fti_used;
ofd->ofd_tot_pending += info->fti_used;
- /* grant more space (twice as much as needed for this request) for
- * precreate purpose if possible */
- ofd_grant(exp, fed->fed_grant, wanted * 2, left, true);
+ /* grant more space for precreate purpose if possible. */
+ wanted = OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace / 2;
+ if (wanted > fed->fed_grant) {
+ /* always try to book enough space to handle a large precreate
+ * request */
+ wanted -= fed->fed_grant;
+ ofd_grant(exp, fed->fed_grant, wanted, left, false);
+ }
spin_unlock(&ofd->ofd_grant_lock);
RETURN(0);
}