Whamcloud - gitweb
b=14385
[fs/lustre-release.git] / lustre / obdfilter / filter_io.c
index 04845a7..1437ba7 100644 (file)
@@ -80,9 +80,6 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
 {
         struct filter_export_data *fed;
         struct obd_device *obd = exp->exp_obd;
-        static unsigned long last_msg;
-        static int last_count;
-        int mask = D_CACHE;
         ENTRY;
 
         LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock);
@@ -96,20 +93,10 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
 
         fed = &exp->exp_filter_data;
 
-        /* Don't print this to the console the first time it happens, since
-         * it can happen legitimately on occasion, but only rarely. */
-        if (time_after(jiffies, last_msg + 60 * HZ)) {
-                last_count = 0;
-                last_msg = jiffies;
-        }
-        if ((last_count & (-last_count)) == last_count)
-                mask = D_HA /* until bug 3273 is fixed D_WARNING */;
-        last_count++;
-
         /* Add some margin, since there is a small race if other RPCs arrive
          * out-or-order and have already consumed some grant.  We want to
          * leave this here in case there is a large error in accounting. */
-        CDEBUG(oa->o_grant > fed->fed_grant + FILTER_GRANT_CHUNK ? mask:D_CACHE,
+        CDEBUG(D_CACHE,
                "%s: cli %s/%p reports grant: "LPU64" dropped: %u, local: %lu\n",
                obd->obd_name, exp->exp_client_uuid.uuid, exp, oa->o_grant,
                oa->o_dropped, fed->fed_grant);
@@ -124,7 +111,7 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
                 oa->o_dirty = fed->fed_grant + 4 * FILTER_GRANT_CHUNK;
         obd->u.filter.fo_tot_dirty += oa->o_dirty - fed->fed_dirty;
         if (fed->fed_grant < oa->o_dropped) {
-                CDEBUG(D_HA,"%s: cli %s/%p reports %u dropped > fedgrant %lu\n",
+                CDEBUG(D_CACHE,"%s: cli %s/%p reports %u dropped > grant %lu\n",
                        obd->obd_name, exp->exp_client_uuid.uuid, exp,
                        oa->o_dropped, fed->fed_grant);
                 oa->o_dropped = 0;
@@ -339,15 +326,15 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                  */
                 LASSERT(lnb->page != NULL);
 
-                if (inode->i_size <= rnb->offset)
+                if (i_size_read(inode) <= rnb->offset)
                         /* If there's no more data, abort early.  lnb->rc == 0,
                          * so it's easy to detect later. */
                         break;
                 else
                         filter_alloc_dio_page(obd, inode, lnb);
 
-                if (inode->i_size < lnb->offset + lnb->len - 1)
-                        lnb->rc = inode->i_size - lnb->offset;
+                if (i_size_read(inode) < lnb->offset + lnb->len - 1)
+                        lnb->rc = i_size_read(inode) - lnb->offset;
                 else
                         lnb->rc = lnb->len;
 
@@ -404,7 +391,7 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
         struct filter_export_data *fed = &exp->exp_filter_data;
         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, mask = D_CACHE;
+        int i, rc = -ENOSPC, obj, n = 0;
 
         LASSERT_SPIN_LOCKED(&exp->exp_obd->obd_osfs_lock);
 
@@ -428,7 +415,6 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
                                                exp->exp_obd->obd_name,
                                                exp->exp_client_uuid.uuid, exp,
                                                used, bytes, fed->fed_grant, n);
-                                        mask = D_RPCTRACE;
                                 } else {
                                         used += bytes;
                                         rnb[n].flags |= OBD_BRW_GRANTED;
@@ -438,7 +424,7 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
                                         continue;
                                 }
                         }
-                        if (*left > ungranted) {
+                        if (*left > ungranted + bytes) {
                                 /* if enough space, pretend it was granted */
                                 ungranted += bytes;
                                 rnb[n].flags |= OBD_BRW_GRANTED;
@@ -472,7 +458,7 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
         exp->exp_obd->u.filter.fo_tot_granted += ungranted;
         exp->exp_obd->u.filter.fo_tot_pending += used + ungranted;
 
-        CDEBUG(mask,
+        CDEBUG(D_CACHE,
                "%s: cli %s/%p used: %lu ungranted: %lu grant: %lu dirty: %lu\n",
                exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp, used,
                ungranted, fed->fed_grant, fed->fed_dirty);
@@ -588,10 +574,8 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
 
         /* 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 (oa->o_valid & OBD_MD_FLGRANT)
                 oa->o_grant = filter_grant(exp,oa->o_grant,oa->o_undirty,left);
-                oa->o_valid |= OBD_MD_FLGRANT;
-        }
 
         spin_unlock(&exp->exp_obd->obd_osfs_lock);
         filter_fmd_put(exp, fmd);
@@ -633,13 +617,13 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
                 if (lnb->len != CFS_PAGE_SIZE) {
                         __s64 maxidx;
 
-                        maxidx = ((dentry->d_inode->i_size + CFS_PAGE_SIZE - 1) >>
-                                 CFS_PAGE_SHIFT) - 1;
+                        maxidx = ((i_size_read(dentry->d_inode) +
+                                   CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT) - 1;
                         if (maxidx >= lnb->page->index) {
                                 LL_CDEBUG_PAGE(D_PAGE, lnb->page, "write %u @ "
                                                LPU64" flg %x before EOF %llu\n",
                                                lnb->len, lnb->offset,lnb->flags,
-                                               dentry->d_inode->i_size);
+                                               i_size_read(dentry->d_inode));
                                 filter_iobuf_add_page(exp->exp_obd, iobuf,
                                                       dentry->d_inode,
                                                       lnb->page);
@@ -713,7 +697,7 @@ void filter_release_read_page(struct filter_obd *filter, struct inode *inode,
         int drop = 0;
 
         if (inode != NULL &&
-            (inode->i_size > filter->fo_readcache_max_filesize))
+            (i_size_read(inode) > filter->fo_readcache_max_filesize))
                 drop = 1;
 
         /* drop from cache like truncate_list_pages() */