Whamcloud - gitweb
- changes about handling CROW flag. URGENT is removed and all create calls are urgent...
authoryury <yury>
Thu, 3 Nov 2005 11:28:28 +0000 (11:28 +0000)
committeryury <yury>
Thu, 3 Nov 2005 11:28:28 +0000 (11:28 +0000)
lustre/include/linux/lustre_idl.h
lustre/llite/file.c
lustre/lov/lov_obd.c
lustre/mds/mds_open.c
lustre/obdclass/llog_lvfs.c
lustre/obdclass/obdo.c
lustre/obdecho/echo_client.c
lustre/obdfilter/filter.c
lustre/osc/osc_create.c

index d2e92c6..f7807c2 100644 (file)
@@ -288,7 +288,6 @@ typedef uint32_t        obd_count;
 #define OBD_FL_NO_USRQUOTA   (0x00000100) /* the object's owner is over quota */
 #define OBD_FL_NO_GRPQUOTA   (0x00000200) /* the object's group is over quota */
 #define OBD_FL_CREATE_CROW   (0x00000400) /* object should be created with crow */
-#define OBD_FL_CREATE_URGENT (0x00000800) /* object should be created asap (echo, llog) */
 
 /* this should be not smaller than sizeof(struct lustre_handle) + sizeof(struct
  * llog_cookie) + sizeof(ll_fid). Nevertheless struct ll_fid is not longer
@@ -329,6 +328,11 @@ struct obdo {
 #define o_dropped o_misc
 #define o_cksum   o_nlink
 
+#define OBDO_URGENT_CREATE(oa)                      \
+        (!((oa)->o_valid & OBD_MD_FLFLAGS) ||       \
+         !((oa)->o_flags & OBD_FL_CREATE_CROW) ||   \
+         ((oa)->o_flags & OBD_FL_RECREATE_OBJS))
+
 extern void lustre_swab_obdo (struct obdo *o);
 
 #define LOV_MAGIC_V1      0x0BD10BD0
index f0fb13e..0d9968f 100644 (file)
@@ -1012,10 +1012,10 @@ static int ll_lov_recreate_obj(struct inode *inode, struct file *file,
 
         oa->o_id = ucreatp.lrc_id;
         oa->o_nlink = ucreatp.lrc_ost_idx;
+        oa->o_flags |= OBD_FL_RECREATE_OBJS;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS;
-        oa->o_flags |= OBD_FL_RECREATE_OBJS | OBD_FL_CREATE_URGENT;
         obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                                   OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+                        OBD_MD_FLMTIME | OBD_MD_FLCTIME);
 
         oti.oti_objid = NULL;
         memcpy(lsm2, lsm, lsm_size);
index 4c82527..4a1b437 100644 (file)
@@ -780,7 +780,7 @@ lov_create(struct obd_export *exp, struct obdo *src_oa,
 
         LASSERT(ergo(src_oa->o_valid & OBD_MD_FLFLAGS,
                      !!(src_oa->o_flags & OBD_FL_CREATE_CROW) !=
-                     !!(src_oa->o_flags & OBD_FL_CREATE_URGENT)));
+                     !!(src_oa->o_flags & OBD_FL_RECREATE_OBJS)));
         
         lov = &exp->exp_obd->u.lov;
         if (!lov->desc.ld_active_tgt_count)
index 6f6d463..8e0d201 100644 (file)
@@ -445,6 +445,12 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
                 oa->o_generation = body->fid1.generation;
                 oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
 
+                /* do not set CROW flag in setattr path as it is not needed
+                 * there and only confuses setattr code in filter. */
+                oa->o_flags &= ~OBD_FL_CREATE_CROW;
+                if (!oa->o_flags)
+                        oa->o_valid &= ~OBD_MD_FLFLAGS;
+                
                 rc = obd_setattr(mds->mds_osc_exp, oa, lsm, &oti);
                 if (rc) {
                         CERROR("error setting attrs for inode %lu: rc %d\n",
index cfcb064..d98fdee 100644 (file)
@@ -517,8 +517,7 @@ static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
                         GOTO(cleanup, rc = -ENOMEM);
 
                 oa->o_gr = FILTER_GROUP_LLOG;
-                oa->o_flags = OBD_FL_CREATE_URGENT;
-                oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLGROUP | OBD_MD_FLFLAGS;
+                oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLGROUP;
 
                 rc = obd_create(ctxt->loc_exp, oa, NULL, NULL);
                 if (rc)
index 7523302..327bf6d 100644 (file)
@@ -125,14 +125,9 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid)
                 attr->ia_valid |= ATTR_GID;
         }
 
-        /* do not set CROW into flags, as it realy does not belong to attributes
-         * and only confuses filter_setattr_internal(). */
         if (valid & OBD_MD_FLFLAGS) {
-                obd_flag o_flags = (oa->o_flags & ~OBD_FL_CREATE_CROW);
-                if (o_flags) {
-                        attr->ia_attr_flags = o_flags;
-                        attr->ia_valid |= ATTR_ATTR_FLAG;
-                }
+                attr->ia_attr_flags = oa->o_flags;
+                attr->ia_valid |= ATTR_ATTR_FLAG;
         }
 }
 EXPORT_SYMBOL(iattr_from_obdo);
index 3787745..11e4ba2 100644 (file)
@@ -223,8 +223,7 @@ static int echo_create_object(struct obd_device *obd, int on_target,
 
         if (on_target) {
                 oa->o_gr = FILTER_GROUP_ECHO;
-                oa->o_flags = OBD_FL_CREATE_URGENT;
-                oa->o_valid |= OBD_MD_FLGROUP | OBD_MD_FLFLAGS;
+                oa->o_valid |= OBD_MD_FLGROUP;
 
                 rc = obd_create(ec->ec_exp, oa, &lsm, oti);
                 if (rc != 0)
index 080b6a4..ef684b6 100644 (file)
@@ -1989,9 +1989,9 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
         if (IS_ERR(handle))
                 GOTO(out_unlock, rc = PTR_ERR(handle));
 
-        if (iattr.ia_valid & ATTR_ATTR_FLAG) {
-                rc = fsfilt_iocontrol(exp->exp_obd, dentry->d_inode, NULL,
-                                      EXT3_IOC_SETFLAGS,
+        if (oa->o_valid & OBD_MD_FLFLAGS) {
+                rc = fsfilt_iocontrol(exp->exp_obd, dentry->d_inode,
+                                      NULL, EXT3_IOC_SETFLAGS,
                                       (long)&iattr.ia_attr_flags);
         } else {
                 rc = fsfilt_setattr(exp->exp_obd, dentry, handle, &iattr, 1);
@@ -2606,10 +2606,24 @@ static int filter_create(struct obd_export *exp, struct obdo *oa,
         CDEBUG(D_INFO, "filter_create(od->o_gr="LPU64",od->o_id="LPU64")\n",
                group, oa->o_id);
 
+        if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags == OBD_FL_DELORPHAN) {
+                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+
+                rc = filter_clear_orphans(exp, oa);
+                if (rc) {
+                        CERROR("cannot clear orphans starting from "
+                               LPU64", err = %d\n", oa->o_id, rc);
+                }
+                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+                RETURN(rc);
+        }
+
+        LASSERT(ergo(oa->o_valid & OBD_MD_FLFLAGS,
+                     !!(oa->o_flags & OBD_FL_CREATE_CROW) !=
+                     !!(oa->o_flags & OBD_FL_RECREATE_OBJS)));
+
         /* echo, llog and other "create asap" cases. */
-        if (oa->o_valid & OBD_MD_FLFLAGS &&
-            (oa->o_flags & OBD_FL_CREATE_URGENT ||
-             oa->o_flags & OBD_FL_RECREATE_OBJS)) {
+        if (OBDO_URGENT_CREATE(oa)) {
                 struct obd_statfs *osfs;
                 struct dentry *dentry;
                 
@@ -2645,22 +2659,11 @@ static int filter_create(struct obd_export *exp, struct obdo *oa,
                                 rc = 0;
                         }
                 }
-
-                RETURN(rc);
-        }
-
-        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
-        LASSERT(oa->o_valid & OBD_MD_FLFLAGS &&
-                oa->o_flags == OBD_FL_DELORPHAN);
-
-        rc = filter_clear_orphans(exp, oa);
-        if (rc) {
-                CERROR("cannot clear orphans starting from "
-                       LPU64", err = %d\n", oa->o_id, rc);
+        } else {
+                CERROR("wrong @oa flags detected 0x%lx. Not an urgent "
+                       "create and not recovery\n", oa->o_flags);
+                LBUG();
         }
-
-        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         RETURN(rc);
 }
 
index 6f9b945..d831832 100644 (file)
@@ -109,6 +109,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                struct lov_stripe_md **ea, struct obd_trans_info *oti)
 {
         struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
+        struct obd_connect_data *ocd;
         int try_again = 1, rc = 0;
         ENTRY;
 
@@ -116,8 +117,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
         LASSERT(ea != NULL);
         
         /* this is the special case where create removes orphans */
-        if ((oa->o_valid & OBD_MD_FLFLAGS) &&
-            oa->o_flags == OBD_FL_DELORPHAN) {
+        if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags == OBD_FL_DELORPHAN) {
                 spin_lock(&oscc->oscc_lock);
                 if (oscc->oscc_flags & OSCC_FLAG_SYNC_IN_PROGRESS) {
                         spin_unlock(&oscc->oscc_lock);
@@ -157,30 +157,21 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                 }
                 spin_unlock(&oscc->oscc_lock);
                 RETURN(rc);
-        } else {
-                struct obd_connect_data *ocd;
-                int urgent;
-
-                ocd = &class_exp2cliimp(exp)->imp_connect_data;
-                
-                urgent = oa->o_valid & OBD_MD_FLFLAGS &&
-                        (oa->o_flags & OBD_FL_CREATE_URGENT ||
-                         oa->o_flags & OBD_FL_RECREATE_OBJS);
-
-                /* perform urgent create if asked or import is not crow capable
-                 * or ENOSPC case if detected. */
-                if (urgent || !OCD_CROW_ABLE(ocd) || osc_check_nospc(exp)) {
-                        /* make sure that all needed flags are set in case of
-                         * real create on enospc case. This is needed to let
-                         * filter know that this is not recovery case.*/
-                        if (osc_check_nospc(exp)) {
-                                oa->o_valid |= OBD_MD_FLFLAGS;
-                                oa->o_flags |= OBD_FL_CREATE_URGENT;
-                        }
-                        CDEBUG(D_HA, "perform urgent create\n");
-                        rc = osc_real_create(exp, oa, ea, oti);
-                        RETURN(rc);
-                }
+        }
+
+        LASSERT(ergo(oa->o_valid & OBD_MD_FLFLAGS,
+                     !!(oa->o_flags & OBD_FL_CREATE_CROW) !=
+                     !!(oa->o_flags & OBD_FL_RECREATE_OBJS)));
+
+        ocd = &class_exp2cliimp(exp)->imp_connect_data;
+
+        /* perform urgent create if asked or import is not crow capable or
+         * ENOSPC case if detected. */
+        if (OBDO_URGENT_CREATE(oa) || !OCD_CROW_ABLE(ocd) ||
+            osc_check_nospc(exp)) {
+                CDEBUG(D_HA, "perform urgent create\n");
+                rc = osc_real_create(exp, oa, ea, oti);
+                RETURN(rc);
         }
 
         /* check OST fs state. */