- struct obd_run_ctxt saved;
- struct obd_ioobj *o;
- struct niobuf_local *lnb;
- struct obd_device *obd = exp->exp_obd;
- int found_locked = 0, rc = 0, i;
- unsigned long now = jiffies; /* DEBUGGING OST TIMEOUTS */
- ENTRY;
-
- push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
-
- LASSERT(current->journal_info == NULL);
- if (cmd & OBD_BRW_WRITE) {
- LASSERT(oti != NULL);
- LASSERT(oti->oti_handle != NULL);
- current->journal_info = oti->oti_handle;
- }
-
- for (i = 0, o = obj, lnb = res; i < objcount; i++, o++) {
- struct inode *inode;
- int j;
-
- /* If all of the page reads were beyond EOF, let's pretend
- * this read didn't really happen at all. */
- if (lnb->dentry == NULL) {
- oa->o_valid = OBD_MD_FLID|(oa->o_valid&OBD_MD_FLCKSUM);
- continue;
- }
-
- inode = igrab(lnb->dentry->d_inode);
-
- if (cmd & OBD_BRW_WRITE) {
- /* FIXME: MULTI OBJECT BRW */
- if (oa && oa->o_valid & (OBD_MD_FLMTIME|OBD_MD_FLCTIME))
- obdo_refresh_inode(inode, oa, OBD_MD_FLATIME |
- OBD_MD_FLMTIME |
- OBD_MD_FLCTIME);
- else
- inode_update_time(lnb->dentry->d_inode, 1);
- } else if (oa && oa->o_valid & OBD_MD_FLATIME) {
- /* Note that we don't necessarily write this to disk */
- obdo_refresh_inode(inode, oa, OBD_MD_FLATIME);
- }
-
- for (j = 0 ; j < o->ioo_bufcnt ; j++, lnb++) {
- if (lnb->page == NULL) {
- continue;
- }
-
- if (lnb->flags & N_LOCAL_TEMP_PAGE) {
- found_locked++;
- continue;
- }
-
- if (time_after(jiffies, lnb->start + 15 * HZ))
- CERROR("slow commitrw %lusi (%lus)\n",
- (jiffies - lnb->start) / HZ,
- (jiffies - now) / HZ);
-
- if (cmd & OBD_BRW_WRITE) {
- int err = filter_commit_write(lnb, 0);
-
- if (!rc)
- rc = err;
- } else {
- page_cache_release(lnb->page);
- }
-
- f_dput(lnb->dentry);
- if (time_after(jiffies, lnb->start + 15 * HZ))
- CERROR("slow commit_write %lus (%lus)\n",
- (jiffies - lnb->start) / HZ,
- (jiffies - now) / HZ);
- }
-
- /* FIXME: MULTI OBJECT BRW */
- if (oa) {
- oa->o_valid = OBD_MD_FLID|(oa->o_valid&OBD_MD_FLCKSUM);
- obdo_from_inode(oa, inode, FILTER_VALID_FLAGS);
- }
-
- if (cmd & OBD_BRW_WRITE)
- up(&inode->i_sem);
-
- iput(inode);
- }
-
- for (i = 0, o = obj, lnb = res; found_locked > 0 && i < objcount;
- i++, o++) {
- int j;
-
- for (j = 0 ; j < o->ioo_bufcnt ; j++, lnb++) {
- int err;
- if (!(lnb->flags & N_LOCAL_TEMP_PAGE))
- continue;
-
- if (time_after(jiffies, lnb->start + 15 * HZ))
- CERROR("slow commitrw locked %lus (%lus)\n",
- (jiffies - lnb->start) / HZ,
- (jiffies - now) / HZ);
-
- err = filter_write_locked_page(lnb);
- if (!rc)
- rc = err;
- f_dput(lnb->dentry);
- found_locked--;
-
- if (time_after(jiffies, lnb->start + 15 * HZ))
- CERROR("slow commit_write locked %lus (%lus)\n",
- (jiffies - lnb->start) / HZ,
- (jiffies - now) / HZ);
- }
- }
-
- if (cmd & OBD_BRW_WRITE) {
- /* We just want any dentry for the commit, for now */
- struct dentry *dparent = filter_parent(obd, S_IFREG, 0);
- int err;
-
- rc = filter_finish_transno(exp, oti, rc);
- err = fsfilt_commit(obd, dparent->d_inode, oti->oti_handle,
- obd_sync_filter);
- LASSERT(current->journal_info == NULL);
- oti->oti_handle = NULL;
- if (err)
- rc = err;
- if (obd_sync_filter)
- LASSERT(oti->oti_transno <= obd->obd_last_committed);
- if (time_after(jiffies, now + 15 * HZ))
- CERROR("slow commitrw commit %lus\n", (jiffies-now)/HZ);
- }
-
- pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
- RETURN(rc);
+ struct filter_obd *filter = &exp->exp_obd->u.filter;
+ struct niobuf_local *lnb = res;
+ unsigned long pending = 0;
+ int i;
+
+ spin_lock(&exp->exp_obd->obd_osfs_lock);
+ for (i = 0, lnb = res; i < niocount; i++, lnb++)
+ pending += lnb->lnb_grant_used;
+
+ LASSERTF(exp->exp_filter_data.fed_pending >= pending,
+ "%s: cli %s/%p fed_pending: %lu grant_used: %lu\n",
+ exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp,
+ exp->exp_filter_data.fed_pending, pending);
+ exp->exp_filter_data.fed_pending -= pending;
+ LASSERTF(filter->fo_tot_granted >= pending,
+ "%s: cli %s/%p tot_granted: "LPU64" grant_used: %lu\n",
+ exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp,
+ exp->exp_obd->u.filter.fo_tot_granted, pending);
+ filter->fo_tot_granted -= pending;
+ LASSERTF(filter->fo_tot_pending >= pending,
+ "%s: cli %s/%p tot_pending: "LPU64" grant_used: %lu\n",
+ exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp,
+ filter->fo_tot_pending, pending);
+ filter->fo_tot_pending -= pending;
+
+ spin_unlock(&exp->exp_obd->obd_osfs_lock);