Whamcloud - gitweb
LU-325 using preallocated objects if OST has enough disk space
[fs/lustre-release.git] / lustre / osc / osc_create.c
index c18183e..b4d5cad 100644 (file)
@@ -132,6 +132,12 @@ static int osc_interpret_create(const struct lu_env *env,
                         if (body && rc == -ENOSPC) {
                                 oscc->oscc_last_id = body->oa.o_id;
                                 oscc->oscc_grow_count = OST_MIN_PRECREATE;
+
+                                if ((body->oa.o_valid & OBD_MD_FLFLAGS) &&
+                                    (body->oa.o_flags & OBD_FL_NOSPC_BLK))
+                                        oscc->oscc_flags |= OSCC_FLAG_NOSPC_BLK;
+                                else
+                                        rc = 0;
                         }
                 }
                 cfs_spin_unlock(&oscc->oscc_lock);
@@ -359,7 +365,7 @@ int osc_precreate(struct obd_export *exp)
 
         /* Handle critical states first */
         cfs_spin_lock(&oscc->oscc_lock);
-        if (oscc->oscc_flags & OSCC_FLAG_NOSPC ||
+        if (oscc->oscc_flags & OSCC_FLAG_NOSPC_BLK ||
             oscc->oscc_flags & OSCC_FLAG_RDONLY ||
             oscc->oscc_flags & OSCC_FLAG_EXITING)
                 GOTO(out, rc = 1000);
@@ -374,6 +380,9 @@ int osc_precreate(struct obd_export *exp)
         /* Return 0, if we have at least one object - bug 22884 */
         rc = oscc_has_objects_nolock(oscc, 1) ? 0 : 1;
 
+        if (oscc->oscc_flags & OSCC_FLAG_NOSPC)
+                GOTO(out, (rc == 0) ? 0 : 1000);
+
         /* Do not check for OSCC_FLAG_CREATING flag here, let
          * osc_precreate() call oscc_internal_create() and
          * adjust oscc_grow_count bug21563 */
@@ -408,7 +417,7 @@ static int handle_async_create(struct ptlrpc_request *req, int rc)
         if (oscc->oscc_flags & OSCC_FLAG_EXITING)
                 GOTO(out_wake, rc = -EIO);
 
-        if (oscc->oscc_flags & OSCC_FLAG_NOSPC)
+        if (oscc->oscc_flags & OSCC_FLAG_NOSPC_BLK)
                 GOTO(out_wake, rc = -ENOSPC);
 
         if (oscc->oscc_flags & OSCC_FLAG_RDONLY)
@@ -577,8 +586,12 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                 if (rc == 0 || rc == -ENOSPC) {
                         struct obd_connect_data *ocd;
 
-                        if (rc == -ENOSPC)
+                        if (rc == -ENOSPC) {
                                 oscc->oscc_flags |= OSCC_FLAG_NOSPC;
+                                if ((oa->o_valid & OBD_MD_FLFLAGS) &&
+                                    (oa->o_flags & OBD_FL_NOSPC_BLK))
+                                        oscc->oscc_flags |= OSCC_FLAG_NOSPC_BLK;
+                        }
                         oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING;
 
                         oscc->oscc_last_id = oa->o_id;
@@ -639,7 +652,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                         break;
                 }
 
-                if (oscc->oscc_flags & OSCC_FLAG_NOSPC) {
+                if (oscc->oscc_flags & OSCC_FLAG_NOSPC_BLK) {
                         rc = -ENOSPC;
                         cfs_spin_unlock(&oscc->oscc_lock);
                         break;
@@ -682,6 +695,12 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                         break;
                 }
 
+                if (oscc->oscc_flags & OSCC_FLAG_NOSPC) {
+                        rc = -ENOSPC;
+                        cfs_spin_unlock(&oscc->oscc_lock);
+                        break;
+                }
+
                 cfs_spin_unlock(&oscc->oscc_lock);
         }