Whamcloud - gitweb
Move obd_getattr from ll_lookup2 to ll_read_inode2
authorpschwan <pschwan>
Thu, 22 Aug 2002 15:16:10 +0000 (15:16 +0000)
committerpschwan <pschwan>
Thu, 22 Aug 2002 15:16:10 +0000 (15:16 +0000)
lustre/llite/namei.c
lustre/llite/super.c

index 3263013..e8542b0 100644 (file)
@@ -134,37 +134,6 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh)
         RETURN(0);
 }
 
-static int ll_file_size(struct inode *inode, struct lov_stripe_md *md,
-                        __u64 *size)
-{
-        struct ll_sb_info *sbi = ll_i2sbi(inode);
-        struct lustre_handle *lockhs;
-        struct obdo oa;
-        int err, rc;
-
-        rc = ll_size_lock(inode, md, 0, LCK_PR, &lockhs);
-        if (rc != ELDLM_OK) {
-                CERROR("lock enqueue: %d\n", rc);
-                RETURN(rc);
-        }
-
-        /* FIXME: I don't like this; why doesn't osc_getattr get o_id from md
-         * like lov_getattr? --phil */
-        oa.o_id = md->lmd_object_id;
-        oa.o_mode = S_IFREG;
-        oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE;
-        rc = obd_getattr(&sbi->ll_osc_conn, &oa, md);
-        if (!rc)
-                *size = oa.o_size;
-
-        err = ll_size_unlock(inode, md, LCK_PR, lockhs);
-        if (err != ELDLM_OK) {
-                CERROR("lock cancel: %d\n", err);
-                LBUG();
-        }
-        RETURN(rc);
-}
-
 static struct dentry *ll_lookup2(struct inode *dir, struct dentry *dentry,
                                  struct lookup_intent *it)
 {
@@ -286,17 +255,6 @@ static struct dentry *ll_lookup2(struct inode *dir, struct dentry *dentry,
                 RETURN(ERR_PTR(-ENOMEM));
         }
 
-        /* Get the authoritative file size */
-#warning FIXME: race condition exists between iget4 and this update!
-        if ((it->it_op & IT_GETATTR) && (inode->i_mode & S_IFREG)) {
-                err = ll_file_size(inode, md.md, &inode->i_size);
-                if (err) {
-                        CERROR("ll_file_size: %d\n", err);
-                        /* FIXME: need to destroy inode here */
-                        GOTO(neg_req, err);
-                }
-        }
-
         EXIT;
  neg_req:
         ptlrpc_free_req(request);
index bb4edef..42ca48c 100644 (file)
@@ -402,6 +402,37 @@ inline int ll_stripe_md_size(struct super_block *sb)
         return mdc->cl_max_mdsize;
 }
 
+static int ll_file_size(struct inode *inode, struct lov_stripe_md *md,
+                        __u64 *size)
+{
+        struct ll_sb_info *sbi = ll_i2sbi(inode);
+        struct lustre_handle *lockhs;
+        struct obdo oa;
+        int err, rc;
+
+        rc = ll_size_lock(inode, md, 0, LCK_PR, &lockhs);
+        if (rc != ELDLM_OK) {
+                CERROR("lock enqueue: %d\n", rc);
+                RETURN(rc);
+        }
+
+        /* FIXME: I don't like this; why doesn't osc_getattr get o_id from md
+         * like lov_getattr? --phil */
+        oa.o_id = md->lmd_object_id;
+        oa.o_mode = S_IFREG;
+        oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE;
+        rc = obd_getattr(&sbi->ll_osc_conn, &oa, md);
+        if (!rc)
+                *size = oa.o_size;
+
+        err = ll_size_unlock(inode, md, LCK_PR, lockhs);
+        if (err != ELDLM_OK) {
+                CERROR("lock cancel: %d\n", err);
+                LBUG();
+        }
+        RETURN(rc);
+}
+
 static void ll_read_inode2(struct inode *inode, void *opaque)
 {
         struct ll_inode_md *md = opaque;
@@ -421,8 +452,6 @@ static void ll_read_inode2(struct inode *inode, void *opaque)
                 inode->i_mtime = body->mtime;
         if (body->valid & OBD_MD_FLCTIME)
                 inode->i_ctime = body->ctime;
-        if (body->valid & OBD_MD_FLSIZE)
-                inode->i_size = body->size;
         if (body->valid & OBD_MD_FLMODE)
                 inode->i_mode = body->mode;
         if (body->valid & OBD_MD_FLUID)
@@ -437,6 +466,20 @@ static void ll_read_inode2(struct inode *inode, void *opaque)
                 inode->i_generation = body->generation;
         if (body->valid & OBD_MD_FLRDEV)
                 inode->i_rdev = body->extra;
+        //if (body->valid & OBD_MD_FLSIZE)
+        //        inode->i_size = body->size;
+
+        /* Get the authoritative file size */
+        if (md && md->md && inode->i_mode & S_IFREG) {
+                int rc;
+                rc = ll_file_size(inode, md->md, &inode->i_size);
+                if (rc) {
+                        CERROR("ll_file_size: %d\n", rc);
+                        /* FIXME: need to somehow prevent inode creation */
+                        LBUG();
+                }
+        }
+
         //if (body->valid & OBD_MD_FLEASIZE)
         if (md && md->md && md->md->lmd_stripe_count) { 
                 struct lov_stripe_md *smd = md->md;