Whamcloud - gitweb
store lustre id in ost object's EA.
authorniu <niu>
Thu, 4 Aug 2005 08:46:29 +0000 (08:46 +0000)
committerniu <niu>
Thu, 4 Aug 2005 08:46:29 +0000 (08:46 +0000)
lustre/llite/llite_lib.c
lustre/llite/rw.c
lustre/lov/lov_obd.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c

index 60e3b79..a2eccc0 100644 (file)
@@ -1313,9 +1313,8 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                         oa->o_valid |= OBD_MD_FLGID;
                 }
 
-                /* putting there also fid, needed for quota too. */
-                memcpy(obdo_id(oa), &lli->lli_id, sizeof(lli->lli_id));
-                oa->o_valid |= OBD_MD_FLINLINE;
+                *(obdo_id(oa)) = lli->lli_id;
+                oa->o_valid |= OBD_MD_FLIFID;
 
                 obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
                                 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
@@ -2146,7 +2145,9 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                 oa->o_id = lsm->lsm_object_id;
                 oa->o_gr = lsm->lsm_object_gr;
                 oa->o_flags = flags;
-                oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
+                *(obdo_id(oa)) = ll_i2info(inode)->lli_id;
+                oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP 
+                              | OBD_MD_FLIFID;
 
                 rc = obd_setattr(sbi->ll_dt_exp, oa, lsm, NULL);
                 obdo_free(oa);
index 8740b0e..434febc 100644 (file)
@@ -217,20 +217,6 @@ int ll_prepare_write(struct file *file, struct page *page,
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLMODE |
                 OBD_MD_FLTYPE | OBD_MD_FLGROUP;
 
-        /*
-         * needed for quota to create OSS object on write with correct
-         * owner/group.
-         */
-        oa->o_uid = inode->i_uid;
-        oa->o_valid |= OBD_MD_FLUID;
-
-        oa->o_gid = inode->i_gid;
-        oa->o_valid |= OBD_MD_FLGID;
-
-        /* putting there also fid, needed for quota too. */
-        memcpy(obdo_id(oa), &lli->lli_id, sizeof(lli->lli_id));
-        oa->o_valid |= OBD_MD_FLINLINE;
-        
         rc = obd_brw(OBD_BRW_CHECK, ll_i2dtexp(inode),
                      oa, lsm, 1, &pga, NULL);
         if (rc)
@@ -264,6 +250,10 @@ int ll_prepare_write(struct file *file, struct page *page,
                 /* bug 1598: don't clobber blksize */
                 oa->o_valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLKSZ);
                 obdo_refresh_inode(inode, oa, oa->o_valid);
+        } else if (rc == -ENOENT) {
+                /* tolerate no entry error here, cause the objects might
+                 * not be created yet */
+                rc = 0;
         }
 
         EXIT;
@@ -368,10 +358,7 @@ void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa)
         valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME;
         if (cmd == OBD_BRW_WRITE) {
                 oa->o_valid |= OBD_MD_FLIFID | OBD_MD_FLEPOCH;
-                mdc_pack_id(obdo_id(oa), inode->i_ino, 0, inode->i_mode, 
-                            id_group(&ll_i2info(inode)->lli_id),
-                            id_fid(&ll_i2info(inode)->lli_id));
-
+                *(obdo_id(oa)) = ll_i2info(inode)->lli_id;
                 oa->o_easize = ll_i2info(inode)->lli_io_epoch;
                 valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
         }
index f429eba..7308d33 100644 (file)
@@ -969,7 +969,7 @@ static int lov_setattr(struct obd_export *exp, struct obdo *src_oa,
                                       OBD_MD_FLCTIME | OBD_MD_FLFLAGS |
                                       OBD_MD_FLSIZE | OBD_MD_FLGROUP |
                                       OBD_MD_FLUID | OBD_MD_FLGID |
-                                      OBD_MD_FLINLINE)));
+                                      OBD_MD_FLINLINE | OBD_MD_FLIFID)));
 
         LASSERT(!(src_oa->o_valid & OBD_MD_FLGROUP) || src_oa->o_gr > 0);
 
index 088550d..ca5f29f 100644 (file)
@@ -2178,8 +2178,6 @@ int filter_setattr(struct obd_export *exp, struct obdo *oa,
         struct filter_obd *filter;
         struct ldlm_resource *res;
         struct dentry *dentry;
-        obd_uid uid;
-        obd_gid gid;
         int rc;
         ENTRY;
 
@@ -2188,12 +2186,9 @@ int filter_setattr(struct obd_export *exp, struct obdo *oa,
         filter = &exp->exp_obd->u.filter;
         push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
 
-        uid = oa->o_valid & OBD_MD_FLUID ? oa->o_uid : 0;
-        gid = oa->o_valid & OBD_MD_FLGID ? oa->o_gid : 0;
         
         /* make sure that object is allocated. */
-        dentry = filter_crow_object(exp->exp_obd, oa->o_gr,
-                                    oa->o_id, uid, gid);
+        dentry = filter_crow_object(exp->exp_obd, oa);
         if (IS_ERR(dentry))
                 GOTO(out_pop, rc = PTR_ERR(dentry));
 
@@ -2307,8 +2302,7 @@ static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         RETURN(rc);
 }
 
-int filter_create_object(struct obd_device *obd, obd_gr group,
-                         obd_id id, obd_uid uid, obd_gid gid)
+int filter_create_object(struct obd_device *obd, struct obdo *oa)
 {
         struct dentry *dparent = NULL;
         struct dentry *dchild = NULL;
@@ -2323,22 +2317,22 @@ int filter_create_object(struct obd_device *obd, obd_gr group,
 
         filter = &obd->u.filter;
 
-        down(&filter->fo_create_locks[group]);
+        down(&filter->fo_create_locks[oa->o_gr]);
 
-        if (test_bit(group, &filter->fo_destroys_in_progress)) {
+        if (test_bit(oa->o_gr, &filter->fo_destroys_in_progress)) {
                 CWARN("%s: create aborted by destroy\n",
                       obd->obd_name);
                 GOTO(out, rc = -EALREADY);
         }
 
-        CDEBUG(D_INFO, "create objid "LPU64"\n", id);
+        CDEBUG(D_INFO, "create objid "LPU64"\n", oa->o_id);
 
-        dparent = filter_parent_lock(obd, group, id, &lock);
+        dparent = filter_parent_lock(obd, oa->o_gr, oa->o_id, &lock);
         if (IS_ERR(dparent))
                 GOTO(cleanup, rc = PTR_ERR(dparent));
         cleanup_phase = 1;
 
-        dchild = filter_id2dentry(obd, dparent, group, id);
+        dchild = filter_id2dentry(obd, dparent, oa->o_gr, oa->o_id);
         if (IS_ERR(dchild))
                 GOTO(cleanup, rc = PTR_ERR(dchild));
         cleanup_phase = 2;
@@ -2352,10 +2346,12 @@ int filter_create_object(struct obd_device *obd, obd_gr group,
                 GOTO(cleanup, rc = PTR_ERR(handle));
         cleanup_phase = 3;
 
-        uc.luc_uid = uid;
-        uc.luc_gid = gid;
-        uc.luc_fsuid = uid;
-        uc.luc_fsgid = gid;
+        uc.luc_uid = oa->o_uid;
+        uc.luc_gid = oa->o_gid;
+        uc.luc_fsuid = oa->o_uid;
+        uc.luc_fsgid = oa->o_gid;
+        uc.luc_cap = current->cap_effective;
+        cap_raise(uc.luc_cap, CAP_SYS_RESOURCE);
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
         rc = ll_vfs_create(dparent->d_inode, dchild, S_IFREG, NULL);
@@ -2366,12 +2362,24 @@ int filter_create_object(struct obd_device *obd, obd_gr group,
                 GOTO(cleanup, rc);
         }
 
+        /* nobody else is touching this newly created object */
+        LASSERT(dchild->d_inode);
+        if (oa->o_valid & OBD_MD_FLIFID) {
+                rc = fsfilt_set_md(obd, dchild->d_inode, handle, obdo_id(oa),
+                                   sizeof(struct lustre_id), EA_SID);
+                if (rc) {
+                        CERROR("store fid in object failed! rc:%d\n", rc);
+                        GOTO(cleanup, rc);
+                }
+        }
+
+
         fsfilt_set_fs_flags(obd, dparent->d_inode, SM_DO_REC);
 
         /* save last created object id */
-        filter_save_last_id(filter, group, id);
+        filter_save_last_id(filter, oa->o_gr, oa->o_id);
 
-        rc = filter_update_last_objid(obd, group, 0);
+        rc = filter_update_last_objid(obd, oa->o_gr, 0);
         if (rc) {
                 CERROR("unable to write lastobjid, but "
                        "orphans were deleted, err = %d\n",
@@ -2400,20 +2408,21 @@ cleanup:
                 GOTO(out, rc);
 
 out:
-        up(&filter->fo_create_locks[group]);
+        up(&filter->fo_create_locks[oa->o_gr]);
         RETURN(rc);
 }
 
 struct dentry *
-filter_crow_object(struct obd_device *obd, __u64 ogr,
-                   __u64 oid, obd_uid uid, obd_gid gid)
+filter_crow_object(struct obd_device *obd, struct obdo *oa)
 {
         struct dentry *dentry;
+        obd_uid uid;
+        obd_gid gid;
         int rc = 0;
         ENTRY;
 
         /* check if object is already allocated */
-        dentry = filter_id2dentry(obd, NULL, ogr, oid);
+        dentry = filter_id2dentry(obd, NULL, oa->o_gr, oa->o_id);
         if (IS_ERR(dentry))
                 RETURN(dentry);
 
@@ -2424,17 +2433,20 @@ filter_crow_object(struct obd_device *obd, __u64 ogr,
         
         CDEBUG(D_INODE, "OSS object "LPU64"/"LPU64
                " does not exists - allocate it now\n",
-               oid, ogr);
+               oa->o_id, oa->o_gr);
 
-        rc = filter_create_object(obd, ogr, oid, uid, gid);
+        uid = oa->o_valid & OBD_MD_FLUID ? oa->o_uid : 0;
+        gid = oa->o_valid & OBD_MD_FLGID ? oa->o_gid : 0;
+
+        rc = filter_create_object(obd, oa);
         if (rc) {
                 CERROR("cannot create OSS object "LPU64"/"LPU64
-                       ", err = %d\n", oid, ogr, rc);
+                       ", err = %d\n", oa->o_id, oa->o_gr, rc);
                 RETURN(ERR_PTR(rc));
         }
 
         /* lookup for just created object and return it to caller */
-        dentry = filter_id2dentry(obd, NULL, ogr, oid);
+        dentry = filter_id2dentry(obd, NULL, oa->o_gr, oa->o_id);
         if (IS_ERR(dentry))
                 RETURN(dentry);
                 
@@ -2442,14 +2454,10 @@ filter_crow_object(struct obd_device *obd, __u64 ogr,
                 f_dput(dentry);
                 dentry = ERR_PTR(-ENOENT);
                 CERROR("cannot find just created OSS object "
-                       LPU64"/"LPU64" err = %d\n", oid,
-                       ogr, (int)PTR_ERR(dentry));
+                       LPU64"/"LPU64" err = %d\n", oa->o_id,
+                       oa->o_gr, (int)PTR_ERR(dentry));
                 RETURN(dentry);
-        } else {
-                /* XXX: here should be storing fid from client into OSS object
-                 * EA to use it for quota later.  --umka */
         }
-
         RETURN(dentry);
 }
 
index c9545d9..0b6af9e 100644 (file)
@@ -111,8 +111,7 @@ int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
                         char *option);
 
-struct dentry *filter_crow_object(struct obd_device *obd, __u64 ogr,
-                                  __u64 oid, obd_uid uid, obd_gid gid);
+struct dentry *filter_crow_object(struct obd_device *obd, struct obdo *oa);
 
 int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
                             struct obdo *oa, struct obd_trans_info *oti);
@@ -120,8 +119,7 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
 int filter_setattr(struct obd_export *exp, struct obdo *oa,
                    struct lov_stripe_md *md, struct obd_trans_info *oti);
 
-int filter_create_object(struct obd_device *obd, obd_gr group, obd_id id,
-                         obd_uid uid, obd_gid gid);
+int filter_create_object(struct obd_device *obd, struct obdo *oa);
 
 /* filter_lvb.c */
 extern struct ldlm_valblock_ops filter_lvbo;
index af7d8ff..643a427 100644 (file)
@@ -506,8 +506,6 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         struct fsfilt_objinfo fso;
         struct obd_device *obd;
         obd_size left;
-        obd_uid uid;
-        obd_gid gid;
         void *iobuf; 
         
         ENTRY;
@@ -524,13 +522,8 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         obd = exp->exp_obd;
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
-        uid = oa->o_valid & OBD_MD_FLUID ? oa->o_uid : 0;
-        gid = oa->o_valid & OBD_MD_FLGID ? oa->o_gid : 0;
-        
         /* make sure that object is already allocated */
-        dentry = filter_crow_object(obd, obj->ioo_gr,
-                                    obj->ioo_id, uid, gid);
-
+        dentry = filter_crow_object(obd, oa);
         if (IS_ERR(dentry))
                 GOTO(cleanup, rc = PTR_ERR(dentry));