* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
fed->fed_grant -= oa->o_dropped;
fed->fed_dirty = oa->o_dirty;
- if (oa->o_flags & OBD_FL_SHRINK_GRANT) {
+ if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags & OBD_FL_SHRINK_GRANT) {
obd_size left_space = filter_grant_space_left(exp);
struct filter_obd *filter = &exp->exp_obd->u.filter;
LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock);
if (cfs_time_before_64(obd->obd_osfs_age,
- cfs_time_current_64() - CFS_HZ)) {
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS))) {
restat:
rc = fsfilt_statfs(obd, obd->u.obt.obt_sb,
- cfs_time_current_64() + CFS_HZ);
+ cfs_time_shift_64(OBD_STATFS_CACHE_SECONDS));
if (rc) /* N.B. statfs can't really fail */
RETURN(0);
statfs_done = 1;
* as we might end up waiting on a page he sent in the request we're serving.
* use __GFP_HIGHMEM so that the pages can use all of the available memory
* on 32-bit machines
- * use more agressive GFP_HIGHUSER flags from non-local clients to be able to
- * generate more memory pressure, but at the same time use __GFP_NOMEMALLOC
- * in order not to exhaust emergency reserves.
+ * use more aggressive GFP_HIGHUSER flags from non-local clients to be able to
+ * generate more memory pressure.
*
* See Bug 19529 and Bug 19917 for details.
*/
LASSERTF(objcount == 1, "%d\n", objcount);
LASSERTF(obj->ioo_bufcnt > 0, "%d\n", obj->ioo_bufcnt);
- LASSERT(oa->o_valid & OBD_MD_FLGROUP);
- rc = filter_auth_capa(exp, NULL, oa->o_gr, capa,
+ rc = filter_auth_capa(exp, NULL, oa->o_seq, capa,
CAPA_OPC_OSS_READ);
if (rc)
RETURN(rc);
cfs_spin_lock(&obd->obd_osfs_lock);
filter_grant_incoming(exp, oa);
- if (!(oa->o_flags & OBD_FL_SHRINK_GRANT))
+ if (!(oa->o_valid & OBD_MD_FLFLAGS) ||
+ !(oa->o_flags & OBD_FL_SHRINK_GRANT))
oa->o_grant = 0;
cfs_spin_unlock(&obd->obd_osfs_lock);
}
RETURN(PTR_ERR(iobuf));
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- dentry = filter_oa2dentry(obd, oa);
+ dentry = filter_oa2dentry(obd, &oa->o_oi);
if (IS_ERR(dentry)) {
rc = PTR_ERR(dentry);
dentry = NULL;
int blocksize = exp->exp_obd->u.obt.obt_sb->s_blocksize;
unsigned long used = 0, ungranted = 0, using;
int i, rc = -ENOSPC, obj, n = 0;
+ int resend = 0;
+
+ if ((oa->o_valid & OBD_MD_FLFLAGS) &&
+ (oa->o_flags & OBD_FL_RECOV_RESEND)) {
+ resend = 1;
+ CDEBUG(D_CACHE, "Recoverable resend arrived, skipping "
+ "accounting\n");
+ }
LASSERT_SPIN_LOCKED(&exp->exp_obd->obd_osfs_lock);
if ((lnb[n].flags & OBD_BRW_FROM_GRANT) &&
(oa->o_valid & OBD_MD_FLGRANT)) {
- if (fed->fed_grant < used + bytes) {
+ if (resend) {
+ /* this is a recoverable resent */
+ lnb[n].flags |= OBD_BRW_GRANTED;
+ rc = 0;
+ continue;
+ } else if (fed->fed_grant < used + bytes) {
CDEBUG(D_CACHE,
"%s: cli %s/%p claims %ld+%d "
"GRANT, real grant %lu idx %d\n",
LASSERT(objcount == 1);
LASSERT(obj->ioo_bufcnt > 0);
- LASSERT(oa->o_valid & OBD_MD_FLGROUP);
- rc = filter_auth_capa(exp, NULL, oa->o_gr, capa,
+ rc = filter_auth_capa(exp, NULL, oa->o_seq, capa,
CAPA_OPC_OSS_WRITE);
if (rc)
RETURN(rc);
GOTO(cleanup, rc = PTR_ERR(iobuf));
cleanup_phase = 1;
- dentry = filter_fid2dentry(obd, NULL, obj->ioo_gr,
+ dentry = filter_fid2dentry(obd, NULL, obj->ioo_seq,
obj->ioo_id);
if (IS_ERR(dentry))
GOTO(cleanup, rc = PTR_ERR(dentry));
cleanup_phase = 2;
if (dentry->d_inode == NULL) {
- CERROR("%s: trying to BRW to non-existent file "LPU64"\n",
- obd->obd_name, obj->ioo_id);
- GOTO(cleanup, rc = -ENOENT);
+ if (exp->exp_obd->obd_recovering) {
+ struct obdo *noa = oa;
+
+ if (oa == NULL) {
+ OBDO_ALLOC(noa);
+ if (noa == NULL)
+ GOTO(recreate_out, rc = -ENOMEM);
+ noa->o_id = obj->ioo_id;
+ noa->o_valid = OBD_MD_FLID;
+ }
+
+ if (filter_create(exp, noa, NULL, oti) == 0) {
+ f_dput(dentry);
+ dentry = filter_fid2dentry(exp->exp_obd, NULL,
+ obj->ioo_seq,
+ obj->ioo_id);
+ }
+ if (oa == NULL)
+ OBDO_FREE(noa);
+ }
+ recreate_out:
+ if (IS_ERR(dentry) || dentry->d_inode == NULL) {
+ CERROR("%s: BRW to missing obj "LPU64"/"LPU64":rc %d\n",
+ exp->exp_obd->obd_name,
+ obj->ioo_id, obj->ioo_seq,
+ IS_ERR(dentry) ? (int)PTR_ERR(dentry) : -ENOENT);
+ if (IS_ERR(dentry))
+ cleanup_phase = 1;
+ GOTO(cleanup, rc = -ENOENT);
+ }
}
if (oa->o_valid & (OBD_MD_FLUID | OBD_MD_FLGID) &&
dentry->d_inode->i_mode & (S_ISUID | S_ISGID)) {
- rc = filter_capa_fixoa(exp, oa, oa->o_gr, capa);
+ rc = filter_capa_fixoa(exp, oa, oa->o_seq, capa);
if (rc)
GOTO(cleanup, rc);
}
fsfilt_check_slow(obd, now, "preprw_write setup");
+ /* Filter truncate first locks i_mutex then partially truncated
+ * page, filter write code first locks pages then take
+ * i_mutex. To avoid a deadlock in case of concurrent
+ * punch/write requests from one client, filter writes and
+ * filter truncates are serialized by i_alloc_sem, allowing
+ * multiple writes or single truncate. */
+ down_read(&dentry->d_inode->i_alloc_sem);
+ fsfilt_check_slow(obd, now, "i_alloc_sem");
+
/* Don't update inode timestamps if this write is older than a
* setattr which modifies the timestamps. b=10150 */
/* XXX when we start having persistent reservations this needs to
* be changed to filter_fmd_get() to create the fmd if it doesn't
* already exist so we can store the reservation handle there. */
- fmd = filter_fmd_find(exp, obj->ioo_id, obj->ioo_gr);
+ fmd = filter_fmd_find(exp, obj->ioo_id, obj->ioo_seq);
LASSERT(oa != NULL);
cfs_spin_lock(&obd->obd_osfs_lock);
/* do not zero out oa->o_valid as it is used in filter_commitrw_write()
* for setting UID/GID and fid EA in first write time. */
- if (oa->o_valid & OBD_MD_FLGRANT)
+ /* If OBD_FL_SHRINK_GRANT is set, the client just returned us some grant
+ * so no sense in allocating it some more. We either return the grant
+ * back to the client if we have plenty of space or we don't return
+ * anything if we are short. This was decided in filter_grant_incoming*/
+ if ((oa->o_valid & OBD_MD_FLGRANT) &&
+ (!(oa->o_valid & OBD_MD_FLFLAGS) ||
+ !(oa->o_flags & OBD_FL_SHRINK_GRANT)))
oa->o_grant = filter_grant(exp, oa->o_grant, oa->o_undirty,
left, 1);
cfs_spin_unlock(&obd->obd_osfs_lock);
filter_fmd_put(exp, fmd);
+ OBD_FAIL_TIMEOUT(OBD_FAIL_OST_BRW_PAUSE_BULK2, (obd_timeout + 1) / 4);
+
if (rc)
GOTO(cleanup, rc);
cleanup_phase = 4;
- /* Filter truncate first locks i_mutex then partally truncated
- * page, filter write code first locks pages then take
- * i_mutex. To avoid a deadlock in case of concurrent
- * punch/write requests from one client, filter writes and
- * filter truncates are serialized by i_alloc_sem, allowing
- * multiple writes or single truncate. */
- down_read(&dentry->d_inode->i_alloc_sem);
-
cfs_gettimeofday(&start);
for (i = 0, lnb = res; i < *npages; i++, lnb++) {
fsfilt_check_slow(obd, now, "start_page_write");
+ lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_WRITE_BYTES,
+ tot_bytes);
+
if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats)
lprocfs_counter_add(exp->exp_nid_stats->nid_stats,
LPROC_FILTER_WRITE_BYTES, tot_bytes);
lnb->page = NULL;
}
}
- up_read(&dentry->d_inode->i_alloc_sem);
}
case 3:
+ if (rc)
+ up_read(&dentry->d_inode->i_alloc_sem);
+
filter_iobuf_put(&obd->u.filter, iobuf, oti);
case 2:
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
int i;
ENTRY;
- osc_build_res_name(obj->ioo_id, obj->ioo_gr, &res_id);
+ osc_build_res_name(obj->ioo_id, obj->ioo_seq, &res_id);
/* If oa != NULL then filter_preprw_read updated the inode atime
* and we should update the lvb so that other glimpses will also
* get the updated value. bug 5972 */
lnb[i].page = pga[i].pg;
rnb[i].offset = pga[i].off;
rnb[i].len = pga[i].count;
+ lnb[i].flags = rnb[i].flags = pga[i].flag;
}
obdo_to_ioobj(oinfo->oi_oa, &ioo);