Whamcloud - gitweb
b=15908
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index 8817868..0c32ba0 100644 (file)
@@ -35,6 +35,7 @@
 #include <lustre_disk.h>
 #include <lustre_param.h>
 #include <lustre_log.h>
+#include <obd_cksum.h>
 #include "llite_internal.h"
 
 cfs_mem_cache_t *ll_file_data_slab;
@@ -75,7 +76,8 @@ static struct ll_sb_info *ll_init_sbi(void)
                                            SBI_DEFAULT_READAHEAD_MAX);
         sbi->ll_ra_info.ra_max_read_ahead_whole_pages =
                                            SBI_DEFAULT_READAHEAD_WHOLE_MAX;
-
+        sbi->ll_contention_time = SBI_DEFAULT_CONTENTION_SECONDS;
+        sbi->ll_lockless_truncate_enable = SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE;
         INIT_LIST_HEAD(&sbi->ll_conn_chain);
         INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list);
 
@@ -104,6 +106,9 @@ static struct ll_sb_info *ll_init_sbi(void)
                 spin_lock_init(&sbi->ll_rw_extents_info.pp_extents[i].pp_w_hist.oh_lock);
         }
 
+        /* metadata statahead is enabled by default */
+        sbi->ll_sa_max = LL_SA_RPC_DEF;
+
         RETURN(sbi);
 }
 
@@ -161,8 +166,7 @@ static int ll_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
         RETURN(rc);
 }
 
-static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
-                                    uid_t nllu, gid_t nllg)
+static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 {
         struct inode *root = 0;
         struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -193,15 +197,16 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
                                                   dt, md);
                 if (err < 0)
-                        CERROR("could not register mount in /proc/lustre");
+                        CERROR("could not register mount in /proc/fs/lustre\n");
         }
 
         /* indicate the features supported by this client */
-        data->ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_NODEVOH |
-                                  OBD_CONNECT_JOIN |
-                                  OBD_CONNECT_ATTRFID | OBD_CONNECT_VERSION |
-                                  OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA |
-                                  OBD_CONNECT_CANCELSET;
+        data->ocd_connect_flags = OBD_CONNECT_IBITS    | OBD_CONNECT_NODEVOH  |
+                                  OBD_CONNECT_JOIN     | OBD_CONNECT_ATTRFID  |
+                                  OBD_CONNECT_VERSION  | OBD_CONNECT_MDS_CAPA |
+                                  OBD_CONNECT_OSS_CAPA | OBD_CONNECT_CANCELSET|
+                                  OBD_CONNECT_FID;
+
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
                 data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
@@ -238,10 +243,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 data->ocd_connect_flags &= ~OBD_CONNECT_RMT_CLIENT;
                 data->ocd_connect_flags |= OBD_CONNECT_LCL_CLIENT;
         }
-        data->ocd_nllu = nllu;
-        data->ocd_nllg = nllg;
 
-        err = obd_connect(NULL, &md_conn, obd, &sbi->ll_sb_uuid, data);
+        err = obd_connect(NULL, &md_conn, obd, &sbi->ll_sb_uuid, data, NULL);
         if (err == -EBUSY) {
                 LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing "
                                    "recovery, of which this client is not a "
@@ -261,7 +264,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 GOTO(out_md, err);
         }
 
-        err = obd_statfs(obd, &osfs, cfs_time_current_64() - HZ);
+        err = obd_statfs(obd, &osfs, cfs_time_current_64() - HZ, 0);
         if (err)
                 GOTO(out_md_fid, err);
 
@@ -364,12 +367,27 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 GOTO(out_md_fid, err = -ENODEV);
         }
 
-        data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION |
+        data->ocd_connect_flags = OBD_CONNECT_GRANT     | OBD_CONNECT_VERSION  |
                                   OBD_CONNECT_REQPORTAL | OBD_CONNECT_BRW_SIZE |
-                                  OBD_CONNECT_CANCELSET;
+                                  OBD_CONNECT_CANCELSET | OBD_CONNECT_FID      |
+                                  OBD_CONNECT_SRVLOCK   | OBD_CONNECT_TRUNCLOCK;
         if (sbi->ll_flags & LL_SBI_OSS_CAPA)
                 data->ocd_connect_flags |= OBD_CONNECT_OSS_CAPA;
 
+        if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) {
+                /* OBD_CONNECT_CKSUM should always be set, even if checksums are
+                 * disabled by default, because it can still be enabled on the
+                 * fly via /proc. As a consequence, we still need to come to an
+                 * agreement on the supported algorithms at connect time */
+                data->ocd_connect_flags |= OBD_CONNECT_CKSUM;
+
+                if (OBD_FAIL_CHECK(OBD_FAIL_OSC_CKSUM_ADLER_ONLY))
+                        data->ocd_cksum_types = OBD_CKSUM_ADLER;
+                else
+                        /* send the list of supported checksum types */
+                        data->ocd_cksum_types = OBD_CKSUM_ALL;
+        }
+
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #endif
@@ -381,7 +399,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         obd->obd_upcall.onu_upcall = ll_ocd_update;
         data->ocd_brw_size = PTLRPC_MAX_BRW_PAGES << CFS_PAGE_SHIFT;
 
-        err = obd_connect(NULL, &dt_conn, obd, &sbi->ll_sb_uuid, data);
+        err = obd_connect(NULL, &dt_conn, obd, &sbi->ll_sb_uuid, data, NULL);
         if (err == -EBUSY) {
                 LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing "
                                    "recovery, of which this client is not a "
@@ -454,9 +472,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 GOTO(out_dt_fid, err);
         }
         memset(&lmd, 0, sizeof(lmd));
-        err = md_get_lustre_md(sbi->ll_md_exp, request, 
-                               REPLY_REC_OFF, sbi->ll_dt_exp, sbi->ll_md_exp, 
-                               &lmd);
+        err = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp,
+                               sbi->ll_md_exp, &lmd);
         if (err) {
                 CERROR("failed to understand root inode md: rc = %d\n", err);
                 ptlrpc_req_finished (request);
@@ -487,6 +504,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 GOTO(out_root, err);
         }
 
+#ifdef CONFIG_FS_POSIX_ACL
+        if (sbi->ll_flags & LL_SBI_RMT_CLIENT) {
+                rct_init(&sbi->ll_rct);
+                et_init(&sbi->ll_et);
+        }
+#endif
+
         checksum = sbi->ll_flags & LL_SBI_CHECKSUM;
         err = obd_set_info_async(sbi->ll_dt_exp, strlen("checksum"),"checksum",
                                  sizeof(checksum), &checksum, NULL);
@@ -675,6 +699,13 @@ void client_common_put_super(struct super_block *sb)
         struct ll_sb_info *sbi = ll_s2sbi(sb);
         ENTRY;
 
+#ifdef CONFIG_FS_POSIX_ACL
+        if (sbi->ll_flags & LL_SBI_RMT_CLIENT) {
+                et_fini(&sbi->ll_et);
+                rct_fini(&sbi->ll_rct);
+        }
+#endif
+
         obd_cancel_unused(sbi->ll_dt_exp, NULL, 0, NULL);
 
         ll_close_thread_shutdown(sbi->ll_lcq);
@@ -883,7 +914,7 @@ int ll_fill_super(struct super_block *sb)
 
         cfs_module_get();
 
-        sb->s_type->fs_flags |= FS_ODD_RENAME;
+        sb->s_type->fs_flags |= FS_RENAME_DOES_D_MOVE;
         /* client additional sb info */
         lsi->lsi_llsbi = sbi = ll_init_sbi();
         if (!sbi) {
@@ -932,9 +963,7 @@ int ll_fill_super(struct super_block *sb)
         sprintf(md, "%s-%s", lprof->lp_md, ll_instance);
 
         /* connections, registrations, sb setup */
-        err = client_common_fill_super(sb, md, dt,
-                                       lsi->lsi_lmd->lmd_nllu,
-                                       lsi->lsi_lmd->lmd_nllg);
+        err = client_common_fill_super(sb, md, dt);
 
 out_free:
         if (md)
@@ -1079,6 +1108,13 @@ void ll_clear_inode(struct inode *inode)
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
                inode->i_generation, inode);
 
+        if (S_ISDIR(inode->i_mode)) {
+                /* these should have been cleared in ll_file_release */
+                LASSERT(lli->lli_sai == NULL);
+                LASSERT(lli->lli_opendir_key == NULL);
+                LASSERT(lli->lli_opendir_pid == 0);
+        }
+
         ll_i2info(inode)->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
         md_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode),
                          null_if_equal, inode);
@@ -1166,8 +1202,8 @@ int ll_md_setattr(struct inode *inode, struct md_op_data *op_data,
                 RETURN(rc);
         }
 
-        rc = md_get_lustre_md(sbi->ll_md_exp, request, REPLY_REC_OFF,
-                              sbi->ll_dt_exp, sbi->ll_md_exp, &md);
+        rc = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp,
+                              sbi->ll_md_exp, &md);
         if (rc) {
                 ptlrpc_req_finished(request);
                 RETURN(rc);
@@ -1220,6 +1256,92 @@ static int ll_setattr_done_writing(struct inode *inode,
         RETURN(rc);
 }
 
+static int ll_setattr_do_truncate(struct inode *inode, loff_t new_size)
+{
+        struct ll_sb_info *sbi = ll_i2sbi(inode);
+        struct ll_inode_info *lli = ll_i2info(inode);
+        struct lov_stripe_md *lsm = lli->lli_smd;
+        int rc;
+        ldlm_policy_data_t policy = { .l_extent = {new_size,
+                                                   OBD_OBJECT_EOF } };
+        struct lustre_handle lockh = { 0 };
+        int local_lock = 0; /* 0 - no local lock;
+                             * 1 - lock taken by lock_extent;
+                             * 2 - by obd_match*/
+        int ast_flags;
+        int err;
+        ENTRY;
+
+        UNLOCK_INODE_MUTEX(inode);
+        UP_WRITE_I_ALLOC_SEM(inode);
+
+        if (sbi->ll_lockless_truncate_enable &&
+            (sbi->ll_lco.lco_flags & OBD_CONNECT_TRUNCLOCK)) {
+                ast_flags = LDLM_FL_BLOCK_GRANTED;
+                rc = obd_match(sbi->ll_dt_exp, lsm, LDLM_EXTENT,
+                               &policy, LCK_PW, &ast_flags, inode, &lockh);
+                if (rc > 0) {
+                        local_lock = 2;
+                        rc = 0;
+                } else if (rc == 0) {
+                        rc = ll_file_punch(inode, new_size, 1);
+                }
+        } else {
+                /* XXX when we fix the AST intents to pass the discard-range
+                 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
+                 * XXX here. */
+                ast_flags = (new_size == 0) ? LDLM_AST_DISCARD_DATA : 0;
+                rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy,
+                                    &lockh, ast_flags);
+                if (likely(rc == 0))
+                        local_lock = 1;
+        }
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+        DOWN_WRITE_I_ALLOC_SEM(inode);
+        LOCK_INODE_MUTEX(inode);
+#else
+        LOCK_INODE_MUTEX(inode);
+        DOWN_WRITE_I_ALLOC_SEM(inode);
+#endif
+        if (likely(rc == 0)) {
+                /* Only ll_inode_size_lock is taken at this level.
+                 * lov_stripe_lock() is grabbed by ll_truncate() only over
+                 * call to obd_adjust_kms().  If vmtruncate returns 0, then
+                 * ll_truncate dropped ll_inode_size_lock() */
+                ll_inode_size_lock(inode, 0);
+                if (!local_lock) {
+                        spin_lock(&lli->lli_lock);
+                        lli->lli_flags |= LLIF_SRVLOCK;
+                        spin_unlock(&lli->lli_lock);
+                }
+                rc = vmtruncate(inode, new_size);
+                if (!local_lock) {
+                        spin_lock(&lli->lli_lock);
+                        lli->lli_flags &= ~LLIF_SRVLOCK;
+                        spin_unlock(&lli->lli_lock);
+                }
+                if (rc != 0) {
+                        LASSERT(atomic_read(&lli->lli_size_sem.count) <= 0);
+                        ll_inode_size_unlock(inode, 0);
+                }
+        }
+
+        if (local_lock) {
+                if (local_lock == 2)
+                        err = obd_cancel(sbi->ll_dt_exp, lsm, LCK_PW, &lockh);
+                else
+                        err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
+                if (unlikely(err != 0)){
+                        CERROR("extent unlock failed: err=%d,"
+                               " unlock method =%d\n", err, local_lock);
+                        if (rc == 0)
+                                rc = err;
+                }
+        }
+        RETURN(rc);
+}
+
 /* If this inode has objects allocated to it (lsm != NULL), then the OST
  * object(s) determine the file size and mtime.  Otherwise, the MDS will
  * keep these values until such a time that objects are allocated for it.
@@ -1291,7 +1413,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
                 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
                        LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
-                       CURRENT_SECONDS);
+                       cfs_time_current_sec());
 
         /* NB: ATTR_SIZE will only be set after this point if the size
          * resides on the MDS, ie, this file has no objects. */
@@ -1304,13 +1426,14 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         OBD_ALLOC_PTR(op_data);
         if (op_data == NULL)
                 RETURN(-ENOMEM);
-        
+
         memcpy(&op_data->op_attr, attr, sizeof(*attr));
 
         /* Open epoch for truncate. */
-        if (ia_valid & ATTR_SIZE)
+        if ((ll_i2mdexp(inode)->exp_connect_flags & OBD_CONNECT_SOM) &&
+            (ia_valid & ATTR_SIZE))
                 op_data->op_flags = MF_EPOCH_OPEN;
-        
+
         rc = ll_md_setattr(inode, op_data, &mod);
         if (rc)
                 GOTO(out, rc);
@@ -1331,43 +1454,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
          * last one is especially bad for racing o_append users on other
          * nodes. */
         if (ia_valid & ATTR_SIZE) {
-                ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
-                                                           OBD_OBJECT_EOF } };
-                struct lustre_handle lockh = { 0 };
-                int err, ast_flags = 0;
-                /* XXX when we fix the AST intents to pass the discard-range
-                 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
-                 * XXX here. */
-                if (attr->ia_size == 0)
-                        ast_flags = LDLM_AST_DISCARD_DATA;
-
-                UNLOCK_INODE_MUTEX(inode);
-                UP_WRITE_I_ALLOC_SEM(inode);
-                rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
-                                    ast_flags);
-                LOCK_INODE_MUTEX(inode);
-                DOWN_WRITE_I_ALLOC_SEM(inode);
-
-                if (rc != 0)
-                        GOTO(out, rc);
-
-                /* Only ll_inode_size_lock is taken at this level.
-                 * lov_stripe_lock() is grabbed by ll_truncate() only over
-                 * call to obd_adjust_kms().  If vmtruncate returns 0, then
-                 * ll_truncate dropped ll_inode_size_lock() */
-                ll_inode_size_lock(inode, 0);
-                rc = vmtruncate(inode, attr->ia_size);
-                if (rc != 0) {
-                        LASSERT(atomic_read(&lli->lli_size_sem.count) <= 0);
-                        ll_inode_size_unlock(inode, 0);
-                }
-
-                err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
-                if (err) {
-                        CERROR("ll_extent_unlock failed: %d\n", err);
-                        if (!rc)
-                                rc = err;
-                }
+                rc = ll_setattr_do_truncate(inode, attr->ia_size);
         } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
                 obd_flag flags;
                 struct obd_info oinfo = { { { 0 } } };
@@ -1423,14 +1510,14 @@ int ll_setattr(struct dentry *de, struct iattr *attr)
 }
 
 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
-                       __u64 max_age)
+                       __u64 max_age, __u32 flags)
 {
         struct ll_sb_info *sbi = ll_s2sbi(sb);
         struct obd_statfs obd_osfs;
         int rc;
         ENTRY;
 
-        rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age);
+        rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age, flags);
         if (rc) {
                 CERROR("md_statfs fails: rc = %d\n", rc);
                 RETURN(rc);
@@ -1442,7 +1529,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
                osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
 
         rc = obd_statfs_rqset(class_exp2obd(sbi->ll_dt_exp),
-                              &obd_osfs, max_age);
+                              &obd_osfs, max_age, flags);
         if (rc) {
                 CERROR("obd_statfs fails: rc = %d\n", rc);
                 RETURN(rc);
@@ -1486,7 +1573,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
         /* For now we will always get up-to-date statfs values, but in the
          * future we may allow some amount of caching on the client (e.g.
          * from QOS or lprocfs updates). */
-        rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - 1);
+        rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - 1, 0);
         if (rc)
                 return rc;
 
@@ -1620,6 +1707,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                 spin_unlock(&lli->lli_lock);
         }
 #endif
+        inode->i_ino = ll_fid_build_ino(sbi, &body->fid1);
+
         if (body->valid & OBD_MD_FLATIME &&
             body->atime > LTIME_S(inode->i_atime))
                 LTIME_S(inode->i_atime) = body->atime;
@@ -1660,25 +1749,6 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                 inode->i_nlink = body->nlink;
         if (body->valid & OBD_MD_FLRDEV)
                 inode->i_rdev = old_decode_dev(body->rdev);
-        if (body->valid & OBD_MD_FLSIZE) {
-                if (ll_i2mdexp(inode)->exp_connect_flags & OBD_CONNECT_SOM) {
-                        if (lli->lli_flags & (LLIF_DONE_WRITING |
-                                              LLIF_EPOCH_PENDING |
-                                              LLIF_SOM_DIRTY))
-                          CWARN("ino %lu flags %lu still has size authority!"
-                                "do not trust the size got from MDS\n", 
-                                inode->i_ino, lli->lli_flags);
-                        else {
-                                i_size_write(inode, body->size);
-                                lli->lli_flags |= LLIF_MDS_SIZE_LOCK;
-                        }
-                } else {
-                        i_size_write(inode, body->size);
-                }
-
-                if (body->valid & OBD_MD_FLBLOCKS)
-                        inode->i_blocks = body->blocks;
-        }
 
         if (body->valid & OBD_MD_FLID) {
                 /* FID shouldn't be changed! */
@@ -1694,6 +1764,44 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 
         LASSERT(fid_seq(&lli->lli_fid) != 0);
 
+        if (body->valid & OBD_MD_FLSIZE) {
+                if ((ll_i2mdexp(inode)->exp_connect_flags & OBD_CONNECT_SOM) &&
+                    S_ISREG(inode->i_mode) && lli->lli_smd) {
+                        struct lustre_handle lockh;
+                        ldlm_mode_t mode;
+                        
+                        /* As it is possible a blocking ast has been processed
+                         * by this time, we need to check there is an UPDATE 
+                         * lock on the client and set LLIF_MDS_SIZE_LOCK holding
+                         * it. */
+                        mode = ll_take_md_lock(inode, MDS_INODELOCK_UPDATE,
+                                               &lockh);
+                        if (mode) {
+                                if (lli->lli_flags & (LLIF_DONE_WRITING |
+                                                      LLIF_EPOCH_PENDING |
+                                                      LLIF_SOM_DIRTY)) {
+                                        CERROR("ino %lu flags %lu still has "
+                                               "size authority! do not trust "
+                                               "the size got from MDS\n",
+                                               inode->i_ino, lli->lli_flags);
+                                } else {
+                                        /* Use old size assignment to avoid
+                                         * deadlock bz14138 & bz14326 */
+                                        inode->i_size = body->size;
+                                        lli->lli_flags |= LLIF_MDS_SIZE_LOCK;
+                                }
+                                ldlm_lock_decref(&lockh, mode);
+                        }
+                } else {
+                        /* Use old size assignment to avoid
+                         * deadlock bz14138 & bz14326 */
+                        inode->i_size = body->size;
+                }
+
+                if (body->valid & OBD_MD_FLBLOCKS)
+                        inode->i_blocks = body->blocks;
+        }
+
         if (body->valid & OBD_MD_FLMDSCAPA) {
                 LASSERT(md->mds_capa);
                 ll_add_capa(inode, md->mds_capa);
@@ -1775,6 +1883,7 @@ void ll_delete_inode(struct inode *inode)
         if (rc) {
                 CERROR("fid_delete() failed, rc %d\n", rc);
         }
+        truncate_inode_pages(&inode->i_data, 0);
         clear_inode(inode);
 
         EXIT;
@@ -1802,11 +1911,11 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                         RETURN(-abs(rc));
                 }
 
-                body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
-                                      sizeof(*body));
+                body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
+
                 flags = body->flags;
 
-                ptlrpc_req_finished (req);
+                ptlrpc_req_finished(req);
 
                 RETURN(put_user(flags, (int *)arg));
         }
@@ -1969,8 +2078,9 @@ int ll_remount_fs(struct super_block *sb, int *flags, char *data)
         return 0;
 }
 
-int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
-                  int offset, struct super_block *sb)
+int ll_prep_inode(struct inode **inode,
+                  struct ptlrpc_request *req,
+                  struct super_block *sb)
 {
         struct ll_sb_info *sbi = NULL;
         struct lustre_md md;
@@ -1982,8 +2092,8 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
         prune_deathrow(sbi, 1);
         memset(&md, 0, sizeof(struct lustre_md));
 
-        rc = md_get_lustre_md(sbi->ll_md_exp, req, offset,
-                              sbi->ll_dt_exp, sbi->ll_md_exp, &md);
+        rc = md_get_lustre_md(sbi->ll_md_exp, req, sbi->ll_dt_exp,
+                              sbi->ll_md_exp, &md);
         if (rc)
                 RETURN(rc);
 
@@ -2027,6 +2137,7 @@ char *llap_origins[] = {
         [LLAP_ORIGIN_READAHEAD] = "ra",
         [LLAP_ORIGIN_COMMIT_WRITE] = "cw",
         [LLAP_ORIGIN_WRITEPAGE] = "wp",
+        [LLAP_ORIGIN_LOCKLESS_IO] = "ls"
 };
 
 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
@@ -2050,12 +2161,10 @@ struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
 int ll_obd_statfs(struct inode *inode, void *arg)
 {
         struct ll_sb_info *sbi = NULL;
-        struct obd_device *client_obd = NULL, *lov_obd = NULL;
-        struct lov_obd *lov = NULL;
-        struct obd_statfs stat_buf = {0};
+        struct obd_export *exp;
         char *buf = NULL;
         struct obd_ioctl_data *data = NULL;
-        __u32 type, index;
+        __u32 type;
         int len = 0, rc;
 
         if (!inode || !(sbi = ll_i2sbi(inode)))
@@ -2071,42 +2180,16 @@ int ll_obd_statfs(struct inode *inode, void *arg)
                 GOTO(out_statfs, rc = -EINVAL);
 
         memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
-        memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
-
-        if (type == LL_STATFS_MDC) {
-                if (index > 0)
-                        GOTO(out_statfs, rc = -ENODEV);
-                client_obd = class_exp2obd(sbi->ll_md_exp);
-        } else if (type == LL_STATFS_LOV) {
-                lov_obd = class_exp2obd(sbi->ll_dt_exp);
-                lov = &lov_obd->u.lov;
-
-                if ((index >= lov->desc.ld_tgt_count))
-                        GOTO(out_statfs, rc = -ENODEV);
-                if (!lov->lov_tgts[index])
-                        /* Try again with the next index */
-                        GOTO(out_statfs, rc = -EAGAIN);
-
-                client_obd = class_exp2obd(lov->lov_tgts[index]->ltd_exp);
-                if (!lov->lov_tgts[index]->ltd_active)
-                        GOTO(out_uuid, rc = -ENODATA);
-        }
-
-        if (!client_obd)
-                GOTO(out_statfs, rc = -EINVAL);
-
-        rc = obd_statfs(client_obd, &stat_buf, cfs_time_current_64() - 1);
+        if (type == LL_STATFS_MDC)
+                exp = sbi->ll_md_exp;
+        else if (type == LL_STATFS_LOV)
+                exp = sbi->ll_dt_exp;
+        else 
+                GOTO(out_statfs, rc = -ENODEV);
+
+        rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL);
         if (rc)
                 GOTO(out_statfs, rc);
-
-        if (copy_to_user(data->ioc_pbuf1, &stat_buf, data->ioc_plen1))
-                GOTO(out_statfs, rc = -EFAULT);
-
-out_uuid:
-        if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(client_obd),
-                         data->ioc_plen2))
-                rc = -EFAULT;
-
 out_statfs:
         if (buf)
                 obd_ioctl_freedata(buf, len);
@@ -2121,7 +2204,7 @@ int ll_process_config(struct lustre_cfg *lcfg)
         unsigned long x; 
         int rc = 0;
 
-        lprocfs_init_vars(llite, &lvars);
+        lprocfs_llite_init_vars(&lvars);
 
         /* The instance name contains the sb: lustre-client-aacfe000 */
         ptr = strrchr(lustre_cfg_string(lcfg, 0), '-');
@@ -2166,12 +2249,13 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data,
                 op_data->op_capa2 = ll_mdscapa_get(i2);
         } else {
                 fid_zero(&op_data->op_fid2);
+                op_data->op_capa2 = NULL;
         }
 
         op_data->op_name = name;
         op_data->op_namelen = namelen;
         op_data->op_mode = mode;
-        op_data->op_mod_time = CURRENT_SECONDS;
+        op_data->op_mod_time = cfs_time_current_sec();
         op_data->op_fsuid = current->fsuid;
         op_data->op_fsgid = current->fsgid;
         op_data->op_cap = current->cap_effective;
@@ -2189,100 +2273,3 @@ void ll_finish_md_op_data(struct md_op_data *op_data)
         capa_put(op_data->op_capa2);
         OBD_FREE_PTR(op_data);
 }
-
-int ll_ioctl_getfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc)
-{
-        struct ll_sb_info *sbi = ll_i2sbi(inode);
-        struct ptlrpc_request *req = NULL;
-        struct mdt_body *body;
-        char *cmd, *buf;
-        struct obd_capa *oc;
-        int rc, buflen;
-        ENTRY;
-
-        if (!(sbi->ll_flags & LL_SBI_RMT_CLIENT))
-                RETURN(-EBADE);
-
-        LASSERT(ioc->cmd && ioc->cmd_len && ioc->res && ioc->res_len);
-
-        OBD_ALLOC(cmd, ioc->cmd_len);
-        if (!cmd)
-                RETURN(-ENOMEM);
-        if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
-                GOTO(out, rc = -EFAULT);
-
-        oc = ll_mdscapa_get(inode);
-        rc = md_getxattr(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), oc,
-                         OBD_MD_FLXATTR, XATTR_NAME_LUSTRE_ACL, cmd,
-                         ioc->cmd_len, ioc->res_len, 0, &req);
-        capa_put(oc);
-        if (rc < 0) {
-                CERROR("mdc_getxattr %s [%s] failed: %d\n",
-                       XATTR_NAME_LUSTRE_ACL, cmd, rc);
-                GOTO(out, rc);
-        }
-
-        body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
-        LASSERT(body);
-
-        buflen = lustre_msg_buflen(req->rq_repmsg, REPLY_REC_OFF);
-        LASSERT(buflen <= ioc->res_len);
-        buf = lustre_msg_string(req->rq_repmsg, REPLY_REC_OFF + 1, ioc->res_len);
-        LASSERT(buf);
-        if (copy_to_user(ioc->res, buf, buflen))
-                GOTO(out, rc = -EFAULT);
-        EXIT;
-out:
-        if (req)
-                ptlrpc_req_finished(req);
-        OBD_FREE(cmd, ioc->cmd_len);
-        return rc;
-}
-
-int ll_ioctl_setfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc)
-{
-        struct ll_sb_info *sbi = ll_i2sbi(inode);
-        struct ptlrpc_request *req = NULL;
-        char *cmd, *buf;
-        struct obd_capa *oc;
-        int buflen, rc;
-        ENTRY;
-
-        if (!(sbi->ll_flags & LL_SBI_RMT_CLIENT))
-                RETURN(-EBADE);
-
-        if (!(sbi->ll_flags & LL_SBI_ACL)) 
-                RETURN(-EOPNOTSUPP);
-
-        LASSERT(ioc->cmd && ioc->cmd_len && ioc->res && ioc->res_len);
-
-        OBD_ALLOC(cmd, ioc->cmd_len);
-        if (!cmd)
-                RETURN(-ENOMEM);
-        if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
-                GOTO(out, rc = -EFAULT);
-
-        oc = ll_mdscapa_get(inode);
-        rc = md_setxattr(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), oc,
-                         OBD_MD_FLXATTR, XATTR_NAME_LUSTRE_ACL, cmd,
-                         ioc->cmd_len, ioc->res_len, 0, &req);
-        capa_put(oc);
-        if (rc) {
-                CERROR("mdc_setxattr %s [%s] failed: %d\n",
-                       XATTR_NAME_LUSTRE_ACL, cmd, rc);
-                GOTO(out, rc);
-        }
-
-        buflen = lustre_msg_buflen(req->rq_repmsg, REPLY_REC_OFF);
-        LASSERT(buflen <= ioc->res_len);
-        buf = lustre_msg_string(req->rq_repmsg, REPLY_REC_OFF, ioc->res_len);
-        LASSERT(buf);
-        if (copy_to_user(ioc->res, buf, buflen))
-                GOTO(out, rc = -EFAULT);
-        EXIT;
-out:
-        if (req)
-                ptlrpc_req_finished(req);
-        OBD_FREE(cmd, ioc->cmd_len);
-        return rc;
-}