Whamcloud - gitweb
Land b1_2 onto HEAD (20040317_2319)
[fs/lustre-release.git] / lustre / obdfilter / filter_io.c
index 7e305f5..773baf4 100644 (file)
@@ -151,7 +151,7 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
         EXIT;
 }
 
-#define GRANT_FOR_LLOG 16
+#define GRANT_FOR_LLOG(obd) 16
 
 /* Figure out how much space is available between what we've granted
  * and what remains in the filesystem.  Compensate for ext3 indirect
@@ -177,8 +177,8 @@ restat:
 
         avail = obd->obd_osfs.os_bavail;
         left = avail - (avail >> (blockbits - 3)); /* (d)indirect */
-        if (left > GRANT_FOR_LLOG) {
-                left = (left - GRANT_FOR_LLOG) << blockbits;
+        if (left > GRANT_FOR_LLOG(obd)) {
+                left = (left - GRANT_FOR_LLOG(obd)) << blockbits;
         } else {
                 left = 0 /* << blockbits */;
         }
@@ -235,10 +235,13 @@ long filter_grant(struct obd_export *exp, obd_size current_grant,
          * avoid overgranting in face of multiple RPCs in flight).  This
          * essentially will be able to control the OSC_MAX_RIF for a client.
          *
-         * If we do have a large disparity and multiple RPCs in flight we
-         * might grant "too much" but that's OK because it means we are
-         * dirtying a lot on the client and will likely use it up quickly. */
+         * If we do have a large disparity between what the client thinks it
+         * has and what we think it has, don't grant very much and let the
+         * client consume its grant first.  Either it just has lots of RPCs
+         * in flight, or it was evicted and its grants will soon be used up. */
         if (current_grant < want) {
+                if (current_grant > fed->fed_grant + FILTER_GRANT_CHUNK)
+                        want = 65536;
                 grant = min((want >> blockbits) / 2,
                             (fs_space_left >> blockbits) / 8);
                 grant <<= blockbits;