Whamcloud - gitweb
- unland b_fid to HEAD
[fs/lustre-release.git] / lustre / llite / file.c
index e30f5ba..117a08c 100644 (file)
@@ -33,7 +33,7 @@
 #include "llite_internal.h"
 #include <linux/obd_lov.h>
 
-int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode,
+int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
                  struct file *file)
 {
         struct ll_file_data *fd = file->private_data;
@@ -53,16 +53,16 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode,
 
         obdo.o_id = inode->i_ino;
         obdo.o_valid = OBD_MD_FLID;
-        obdo_from_inode(&obdo, inode, (OBD_MD_FLTYPE | OBD_MD_FLMODE |
-                                       OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
-                                       OBD_MD_FLATIME | OBD_MD_FLMTIME |
-                                       OBD_MD_FLCTIME));
+        obdo_from_inode(&obdo, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE |
+                                      OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
+                                      OBD_MD_FLATIME | OBD_MD_FLMTIME |
+                                      OBD_MD_FLCTIME);
         if (0 /* ll_is_inode_dirty(inode) */) {
                 obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;
                 obdo.o_valid |= OBD_MD_FLFLAGS;
         }
-        obdo.o_mds = id_group(&ll_i2info(inode)->lli_id);
-        rc = md_close(lmv_exp, &obdo, och, &req);
+        obdo.o_mds = ll_i2info(inode)->lli_mds;
+        rc = md_close(mdc_exp, &obdo, och, &req);
 
         if (rc == EAGAIN) {
                 /* We are the last writer, so the MDS has instructed us to get
@@ -80,7 +80,7 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode,
                                inode->i_ino, rc);
         }
 
-        mdc_clear_open_replay_data(lmv_exp, och);
+        mdc_clear_open_replay_data(mdc_exp, och);
         ptlrpc_req_finished(req);
         och->och_fh.cookie = DEAD_HANDLE_MAGIC;
         file->private_data = NULL;
@@ -101,8 +101,9 @@ int ll_file_release(struct inode *inode, struct file *file)
         int rc;
 
         ENTRY;
-        CDEBUG(D_VFSTRACE, "VFS Op:inode="DLID4"(%p)\n",
-               OLID4(&ll_i2info(inode)->lli_id), inode);
+        CDEBUG(D_VFSTRACE, "VFS Op:inode=%u/%lu/%u(%p)\n",
+               ll_i2info(inode)->lli_mds, inode->i_ino,
+               inode->i_generation, inode);
 
         /* don't do anything for / */
         if (inode->i_sb->s_root == file->f_dentry)
@@ -112,7 +113,7 @@ int ll_file_release(struct inode *inode, struct file *file)
         fd = (struct ll_file_data *)file->private_data;
         LASSERT(fd != NULL);
 
-        rc = ll_mdc_close(sbi->ll_lmv_exp, inode, file);
+        rc = ll_mdc_close(sbi->ll_mdc_exp, inode, file);
         RETURN(rc);
 }
 
@@ -130,9 +131,9 @@ static int ll_intent_file_open(struct file *file, void *lmm,
         if (!parent)
                 RETURN(-ENOENT);
 
-        ll_prepare_mdc_data(&data, parent->d_inode, NULL, name, len, O_RDWR);
+        ll_prepare_mdc_op_data(&data, parent->d_inode, NULL, name, len, O_RDWR);
 
-        rc = md_enqueue(sbi->ll_lmv_exp, LDLM_IBITS, itp, LCK_PR, &data,
+        rc = md_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, itp, LCK_PR, &data,
                         &lockh, lmm, lmmsize, ldlm_completion_ast,
                         ll_mdc_blocking_ast, NULL);
         if (rc == 0) {
@@ -150,7 +151,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it)
 {
         struct ptlrpc_request *req = it->d.lustre.it_data;
         struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
-        struct obd_export *lmv_exp = ll_i2lmvexp(file->f_dentry->d_inode);
+        struct obd_export *mdc_exp = ll_i2mdcexp(file->f_dentry->d_inode);
         struct ll_file_data *fd;
         struct mds_body *body;
         ENTRY;
@@ -169,7 +170,6 @@ int ll_local_open(struct file *file, struct lookup_intent *it)
 
 
         OBD_SLAB_ALLOC(fd, ll_file_data_slab, SLAB_KERNEL, sizeof *fd);
-        
         /* We can't handle this well without reorganizing ll_file_open and
          * ll_mdc_close, so don't even try right now. */
         LASSERT(fd != NULL);
@@ -181,7 +181,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it)
 
         lli->lli_io_epoch = body->io_epoch;
 
-        mdc_set_open_replay_data(lmv_exp, &fd->fd_mds_och, it->d.lustre.it_data);
+        mdc_set_open_replay_data(mdc_exp, &fd->fd_mds_och, it->d.lustre.it_data);
 
         RETURN(0);
 }
@@ -678,7 +678,7 @@ int ll_glimpse_size(struct inode *inode)
 
         CDEBUG(D_DLMTRACE, "Glimpsing inode %lu\n", inode->i_ino);
 
-        rc = obd_enqueue(sbi->ll_lov_exp, lli->lli_smd, LDLM_EXTENT, &policy,
+        rc = obd_enqueue(sbi->ll_osc_exp, lli->lli_smd, LDLM_EXTENT, &policy,
                          LCK_PR, &flags, ll_extent_lock_callback,
                          ldlm_completion_ast, ll_glimpse_callback, inode,
                          sizeof(struct ost_lvb), lustre_swab_ost_lvb, &lockh);
@@ -694,9 +694,10 @@ int ll_glimpse_size(struct inode *inode)
         inode->i_blocks = lov_merge_blocks(lli->lli_smd);
         //inode->i_mtime = lov_merge_mtime(lli->lli_smd, inode->i_mtime);
 
-        CDEBUG(D_DLMTRACE, "glimpse: size: "LPU64", blocks: "LPU64"\n",
-               (__u64)inode->i_size, (__u64)inode->i_blocks);
-        obd_cancel(sbi->ll_lov_exp, lli->lli_smd, LCK_PR, &lockh);
+        CDEBUG(D_DLMTRACE, "glimpse: size: %llu, blocks: %lu\n",
+               inode->i_size, inode->i_blocks);
+        obd_cancel(sbi->ll_osc_exp, lli->lli_smd, LCK_PR, &lockh);
+
         RETURN(rc);
 }
 
@@ -732,7 +733,8 @@ int ll_extent_lock(struct ll_file_data *fd, struct inode *inode,
                inode->i_ino, policy->l_extent.start, policy->l_extent.end);
 
         do_gettimeofday(&start);
-        rc = obd_enqueue(sbi->ll_lov_exp, lsm, LDLM_EXTENT, policy, mode,
+        
+        rc = obd_enqueue(sbi->ll_osc_exp, lsm, LDLM_EXTENT, policy, mode,
                          &ast_flags, ll_extent_lock_callback,
                          ldlm_completion_ast, ll_glimpse_callback, inode,
                          sizeof(struct ost_lvb), lustre_swab_ost_lvb, lockh);
@@ -773,7 +775,7 @@ int ll_extent_unlock(struct ll_file_data *fd, struct inode *inode,
             (sbi->ll_flags & LL_SBI_NOLCK))
                 RETURN(0);
 
-        rc = obd_cancel(sbi->ll_lov_exp, lsm, mode, lockh);
+        rc = obd_cancel(sbi->ll_osc_exp, lsm, mode, lockh);
 
         RETURN(rc);
 }
@@ -811,6 +813,7 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count,
 
         rc = ll_tree_lock(&tree, node, inode, buf, count,
                           file->f_flags & O_NONBLOCK ? LDLM_FL_BLOCK_NOWAIT :0);
+        
         if (rc != 0)
                 RETURN(rc);
 
@@ -841,11 +844,8 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count,
         RETURN(retval);
 }
 
-/*
- * Write to a file (through the page cache).
- */
-static ssize_t ll_file_write(struct file *file, const char *buf,
-                             size_t count, loff_t *ppos)
+static ssize_t ll_file_write(struct file *file, const char *buf, size_t count,
+                             loff_t *ppos)
 {
         struct inode *inode = file->f_dentry->d_inode;
         loff_t maxbytes = ll_file_maxbytes(inode);
@@ -958,7 +958,7 @@ static int ll_lov_recreate_obj(struct inode *inode, struct file *file,
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLFLAGS;
         oa->o_flags |= OBD_FL_RECREATE_OBJS;
         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);
@@ -1013,7 +1013,7 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
         if (rc < 0)
                 GOTO(out, rc);
 
-        rc = mdc_req2lustre_md(ll_i2lmvexp(inode), req, 1, exp, &md);
+        rc = mdc_req2lustre_md(ll_i2mdcexp(inode), req, 1, exp, &md);
         if (rc)
                 GOTO(out, rc);
         ll_update_inode(f->f_dentry->d_inode, &md);
@@ -1276,7 +1276,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
 {
         struct inode *inode = dentry->d_inode;
         struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
-        struct lustre_id id;
+        struct ll_fid fid;
         struct ptlrpc_request *req;
         int rc, err;
         ENTRY;
@@ -1289,8 +1289,8 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
          * that IO to finish before calling the osc and mdc sync methods */
         rc = filemap_fdatawait(inode->i_mapping);
 
-        ll_inode2id(&id, inode);
-        err = md_sync(ll_i2sbi(inode)->ll_lmv_exp, &id, &req);
+        ll_inode2fid(&fid, inode);
+        err = md_sync(ll_i2sbi(inode)->ll_mdc_exp, &fid, &req);
         if (!rc)
                 rc = err;
         if (!err)
@@ -1305,11 +1305,11 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                 oa->o_id = lsm->lsm_object_id;
                 oa->o_gr = lsm->lsm_object_gr;
                 oa->o_valid = OBD_MD_FLID;
-                obdo_from_inode(oa, inode, (OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                                            OBD_MD_FLMTIME | OBD_MD_FLCTIME |
-                                            OBD_MD_FLGROUP));
+                obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
+                                           OBD_MD_FLMTIME | OBD_MD_FLCTIME |
+                                           OBD_MD_FLGROUP);
 
-                err = obd_sync(ll_i2sbi(inode)->ll_lov_exp, oa, lsm,
+                err = obd_sync(ll_i2sbi(inode)->ll_osc_exp, oa, lsm,
                                0, OBD_OBJECT_EOF);
                 if (!rc)
                         rc = err;
@@ -1322,11 +1322,10 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
 int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
 {
         struct inode *inode = file->f_dentry->d_inode;
-        struct ll_inode_info *li = ll_i2info(inode);
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct obd_device *obddev;
         struct ldlm_res_id res_id =
-                { .name = {id_fid(&li->lli_id), id_group(&li->lli_id), LDLM_FLOCK} };
+                    { .name = {inode->i_ino, inode->i_generation, LDLM_FLOCK} };
         struct lustre_handle lockh = {0};
         ldlm_policy_data_t flock;
         ldlm_mode_t mode = 0;
@@ -1395,7 +1394,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
                "start="LPU64", end="LPU64"\n", inode->i_ino, flock.l_flock.pid,
                flags, mode, flock.l_flock.start, flock.l_flock.end);
 
-        obddev = md_get_real_obd(sbi->ll_lmv_exp, NULL, 0);
+        obddev = md_get_real_obd(sbi->ll_mdc_exp, NULL, 0);
         rc = ldlm_cli_enqueue(obddev->obd_self_export, NULL,
                               obddev->obd_namespace,
                               res_id, LDLM_FLOCK, &flock, mode, &flags,
@@ -1409,10 +1408,10 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it)
         struct inode *inode = dentry->d_inode;
         struct ll_inode_info *lli;
         struct lov_stripe_md *lsm;
-        struct lustre_id id;
         struct ptlrpc_request *req = NULL;
         struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
         struct lookup_intent oit = { .it_op = IT_GETATTR };
+        struct ll_fid  cfid;
         int rc;
         
         ENTRY;
@@ -1421,21 +1420,17 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it)
                 CERROR("REPORT THIS LINE TO PETER\n");
                 RETURN(0);
         }
-        
-        ll_inode2id(&id, inode);
         lli = ll_i2info(inode);
-        LASSERT(id_fid(&id) != 0);
-
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%s,intent=%s\n",
                inode->i_ino, inode->i_generation, inode, dentry->d_name.name,
                LL_IT2STR(it));
-
 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0))
         lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_REVALIDATE);
 #endif
 
-        rc = md_intent_lock(sbi->ll_lmv_exp, &id,
-                            NULL, 0, NULL, 0, &id, &oit, 0, &req,
+        ll_inode2fid(&cfid, dentry->d_inode);
+        rc = md_intent_lock(sbi->ll_mdc_exp, &cfid,
+                            NULL, 0, NULL, 0, &cfid, &oit, 0, &req,
                             ll_mdc_blocking_ast);
         if (rc < 0)
                 GOTO(out, rc);