Whamcloud - gitweb
b=1028 drop SOM dependency on quota
[fs/lustre-release.git] / lustre / osd / osd_handler.c
index 7fc790f..302923c 100644 (file)
@@ -97,18 +97,18 @@ struct osd_object {
         /**
          * to protect index ops.
          */
-        struct rw_semaphore    oo_ext_idx_sem;
-        struct rw_semaphore    oo_sem;
+        cfs_rw_semaphore_t     oo_ext_idx_sem;
+        cfs_rw_semaphore_t     oo_sem;
         struct osd_directory  *oo_dir;
         /** protects inode attributes. */
-        spinlock_t             oo_guard;
+        cfs_spinlock_t         oo_guard;
         /**
          * Following two members are used to indicate the presence of dot and
          * dotdot in the given directory. This is required for interop mode
          * (b11826).
          */
-        int oo_compat_dot_created;
-        int oo_compat_dotdot_created;
+        int                    oo_compat_dot_created;
+        int                    oo_compat_dotdot_created;
 
         const struct lu_env   *oo_owner;
 #ifdef CONFIG_LOCKDEP
@@ -286,9 +286,9 @@ static struct lu_object *osd_object_alloc(const struct lu_env *env,
                         mo->oo_dt.do_ops = &osd_obj_ops;
 
                 l->lo_ops = &osd_lu_obj_ops;
-                init_rwsem(&mo->oo_sem);
-                init_rwsem(&mo->oo_ext_idx_sem);
-                spin_lock_init(&mo->oo_guard);
+                cfs_init_rwsem(&mo->oo_sem);
+                cfs_init_rwsem(&mo->oo_ext_idx_sem);
+                cfs_spin_lock_init(&mo->oo_guard);
                 return l;
         } else
                 return NULL;
@@ -710,7 +710,7 @@ static void osd_object_release(const struct lu_env *env,
 
         LASSERT(!lu_object_is_dying(l->lo_header));
         if (o->oo_inode != NULL && osd_inode_unlinked(o->oo_inode))
-                set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
+                cfs_set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
 }
 
 /*
@@ -737,13 +737,13 @@ static int osd_object_print(const struct lu_env *env, void *cookie,
  * Concurrency: shouldn't matter.
  */
 int osd_statfs(const struct lu_env *env, struct dt_device *d,
-               struct kstatfs *sfs)
+               cfs_kstatfs_t *sfs)
 {
         struct osd_device *osd = osd_dt_dev(d);
         struct super_block *sb = osd_sb(osd);
         int result = 0;
 
-        spin_lock(&osd->od_osfs_lock);
+        cfs_spin_lock(&osd->od_osfs_lock);
         /* cache 1 second */
         if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) {
                 result = ll_do_statfs(sb, &osd->od_kstatfs);
@@ -753,7 +753,7 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d,
 
         if (likely(result == 0))
                 *sfs = osd->od_kstatfs;
-        spin_unlock(&osd->od_osfs_lock);
+        cfs_spin_unlock(&osd->od_osfs_lock);
 
         return result;
 }
@@ -907,8 +907,8 @@ static const int osd_dto_credits_noquota[DTO_NR] = {
         /**
          * Xattr set. The same as xattr of EXT3.
          * DATA_TRANS_BLOCKS(14)
-         * XXX Note: in original MDS implmentation INDEX_EXTRA_TRANS_BLOCKS are
-         *           also counted in. Do not know why?
+         * XXX Note: in original MDS implmentation INDEX_EXTRA_TRANS_BLOCKS
+         * are also counted in. Do not know why?
          */
         [DTO_XATTR_SET]     = 14,
         [DTO_LOG_REC]       = 14,
@@ -922,9 +922,9 @@ static const int osd_dto_credits_noquota[DTO_NR] = {
         [DTO_WRITE_BLOCK]   = 14,
         /**
          * Attr set credits for chown.
-         * 3 (inode bit, group, GDT)
+         * This is extra credits for setattr, and it is null without quota
          */
-        [DTO_ATTR_SET_CHOWN]= 3
+        [DTO_ATTR_SET_CHOWN]= 0
 };
 
 /**
@@ -987,11 +987,11 @@ static const int osd_dto_credits_quota[DTO_NR] = {
         [DTO_WRITE_BLOCK]   = 16,
         /**
          * Attr set credits for chown.
-         * 3 (inode bit, group, GDT) +
+         * It is added to already set setattr credits
          * 2 * QUOTA_INIT_BLOCKS(25) +
          * 2 * QUOTA_DEL_BLOCKS(9)
          */
-        [DTO_ATTR_SET_CHOWN]= 71
+        [DTO_ATTR_SET_CHOWN]= 68,
 };
 
 static int osd_credit_get(const struct lu_env *env, struct dt_device *d,
@@ -1031,7 +1031,7 @@ static void osd_object_read_lock(const struct lu_env *env,
         LINVRNT(osd_invariant(obj));
 
         LASSERT(obj->oo_owner != env);
-        down_read_nested(&obj->oo_sem, role);
+        cfs_down_read_nested(&obj->oo_sem, role);
 
         LASSERT(obj->oo_owner == NULL);
         oti->oti_r_locks++;
@@ -1046,7 +1046,7 @@ static void osd_object_write_lock(const struct lu_env *env,
         LINVRNT(osd_invariant(obj));
 
         LASSERT(obj->oo_owner != env);
-        down_write_nested(&obj->oo_sem, role);
+        cfs_down_write_nested(&obj->oo_sem, role);
 
         LASSERT(obj->oo_owner == NULL);
         obj->oo_owner = env;
@@ -1063,7 +1063,7 @@ static void osd_object_read_unlock(const struct lu_env *env,
 
         LASSERT(oti->oti_r_locks > 0);
         oti->oti_r_locks--;
-        up_read(&obj->oo_sem);
+        cfs_up_read(&obj->oo_sem);
 }
 
 static void osd_object_write_unlock(const struct lu_env *env,
@@ -1078,7 +1078,7 @@ static void osd_object_write_unlock(const struct lu_env *env,
         LASSERT(oti->oti_w_locks > 0);
         oti->oti_w_locks--;
         obj->oo_owner = NULL;
-        up_write(&obj->oo_sem);
+        cfs_up_write(&obj->oo_sem);
 }
 
 static int osd_object_write_locked(const struct lu_env *env,
@@ -1117,14 +1117,14 @@ static int capa_is_sane(const struct lu_env *env,
                 RETURN(-ESTALE);
         }
 
-        spin_lock(&capa_lock);
+        cfs_spin_lock(&capa_lock);
         for (i = 0; i < 2; i++) {
                 if (keys[i].lk_keyid == capa->lc_keyid) {
                         oti->oti_capa_key = keys[i];
                         break;
                 }
         }
-        spin_unlock(&capa_lock);
+        cfs_spin_unlock(&capa_lock);
 
         if (i == 2) {
                 DEBUG_CAPA(D_ERROR, capa, "no matched capa key");
@@ -1239,9 +1239,9 @@ static int osd_attr_get(const struct lu_env *env,
         if (osd_object_auth(env, dt, capa, CAPA_OPC_META_READ))
                 return -EACCES;
 
-        spin_lock(&obj->oo_guard);
+        cfs_spin_lock(&obj->oo_guard);
         osd_inode_getattr(env, obj->oo_inode, attr);
-        spin_unlock(&obj->oo_guard);
+        cfs_spin_unlock(&obj->oo_guard);
         return 0;
 }
 
@@ -1287,13 +1287,12 @@ static int osd_inode_setattr(const struct lu_env *env,
                 i_size_write(inode, attr->la_size);
         }
 
+#if 0
         /* OSD should not change "i_blocks" which is used by quota.
-         * "i_blocks" should be changed by ldiskfs only.
-         * Enable this assignment for SOM purpose now, until it is
-         * stored in SOM EA. */
+         * "i_blocks" should be changed by ldiskfs only. */
         if (bits & LA_BLOCKS)
                 inode->i_blocks = attr->la_blocks;
-
+#endif
         if (bits & LA_MODE)
                 inode->i_mode   = (inode->i_mode & S_IFMT) |
                         (attr->la_mode & ~S_IFMT);
@@ -1331,9 +1330,9 @@ static int osd_attr_set(const struct lu_env *env,
         if (osd_object_auth(env, dt, capa, CAPA_OPC_META_WRITE))
                 return -EACCES;
 
-        spin_lock(&obj->oo_guard);
+        cfs_spin_lock(&obj->oo_guard);
         rc = osd_inode_setattr(env, obj->oo_inode, attr);
-        spin_unlock(&obj->oo_guard);
+        cfs_spin_unlock(&obj->oo_guard);
 
         if (!rc)
                 mark_inode_dirty(obj->oo_inode);
@@ -1380,7 +1379,7 @@ static struct dentry * osd_child_dentry_get(const struct lu_env *env,
 
 
 static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj,
-                      umode_t mode,
+                      cfs_umode_t mode,
                       struct dt_allocation_hint *hint,
                       struct thandle *th)
 {
@@ -1522,7 +1521,7 @@ static int osd_mknod(struct osd_thread_info *info, struct osd_object *obj,
                      struct dt_object_format *dof,
                      struct thandle *th)
 {
-        umode_t mode = attr->la_mode & (S_IFMT | S_IRWXUGO | S_ISVTX);
+        cfs_umode_t mode = attr->la_mode & (S_IFMT | S_IRWXUGO | S_ISVTX);
         int result;
 
         LINVRNT(osd_invariant(obj));
@@ -1575,7 +1574,7 @@ static osd_obj_type_f osd_create_type_f(enum dt_format_type type)
 
 
 static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah,
-                        struct dt_object *parent, umode_t child_mode)
+                        struct dt_object *parent, cfs_umode_t child_mode)
 {
         LASSERT(ah);
 
@@ -1687,9 +1686,9 @@ static int __osd_xattr_set(const struct lu_env *env, struct dt_object *dt,
         rc = inode->i_op->setxattr(dentry, name, buf->lb_buf,
                                    buf->lb_len, fs_flags);
         /* ctime should not be updated with server-side time. */
-        spin_lock(&obj->oo_guard);
+        cfs_spin_lock(&obj->oo_guard);
         inode->i_ctime = *t;
-        spin_unlock(&obj->oo_guard);
+        cfs_spin_unlock(&obj->oo_guard);
         mark_inode_dirty(inode);
         return rc;
 }
@@ -1710,8 +1709,8 @@ static int osd_ea_fid_set(const struct lu_env *env, struct dt_object *dt,
         struct osd_thread_info  *info      = osd_oti_get(env);
         struct lustre_mdt_attrs *mdt_attrs = &info->oti_mdt_attrs;
 
-        fid_cpu_to_be(&mdt_attrs->lma_self_fid, fid);
-
+        lustre_lma_init(mdt_attrs, fid);
+        lustre_lma_swab(mdt_attrs);
         return __osd_xattr_set(env, dt,
                                osd_buf_get(env, mdt_attrs, sizeof *mdt_attrs),
                                XATTR_NAME_LMA, LU_XATTR_CREATE);
@@ -1759,9 +1758,9 @@ int osd_fid_unpack(struct lu_fid *fid, const struct osd_fid_pack *pack)
  * Try to read the fid from inode ea into dt_rec, if return value
  * i.e. rc is +ve, then we got fid, otherwise we will have to form igif
  *
- * \param fid, object fid.
+ * \param fid object fid.
  *
- * \retval 0, on success
+ * \retval 0 on success
  */
 static int osd_ea_fid_get(const struct lu_env *env, struct osd_object *obj,
                           __u32 ino, struct lu_fid *fid)
@@ -1794,15 +1793,16 @@ static int osd_ea_fid_get(const struct lu_env *env, struct osd_object *obj,
 
         /* Check LMA compatibility */
         if (rc > 0 &&
-            (mdt_attrs->lma_incompat & ~cpu_to_be32(LMA_INCOMPAT_SUPP))) {
+            (mdt_attrs->lma_incompat & ~cpu_to_le32(LMA_INCOMPAT_SUPP))) {
                 CWARN("Inode %lx: Unsupported incompat LMA feature(s) %#x\n",
-                      inode->i_ino, be32_to_cpu(mdt_attrs->lma_incompat) &
+                      inode->i_ino, le32_to_cpu(mdt_attrs->lma_incompat) &
                       ~LMA_INCOMPAT_SUPP);
                 return -ENOSYS;
         }
 
         if (rc > 0) {
-                fid_be_to_cpu(fid, &mdt_attrs->lma_self_fid);
+                lustre_lma_swab(mdt_attrs);
+                memcpy(fid, &mdt_attrs->lma_self_fid, sizeof(*fid));
                 rc = 0;
         } else if (rc == -ENODATA) {
                 osd_igif_get(env, inode, fid);
@@ -1873,10 +1873,10 @@ static void osd_object_ref_add(const struct lu_env *env,
         LASSERT(osd_write_locked(env, obj));
         LASSERT(th != NULL);
 
-        spin_lock(&obj->oo_guard);
+        cfs_spin_lock(&obj->oo_guard);
         LASSERT(inode->i_nlink < LDISKFS_LINK_MAX);
         inode->i_nlink++;
-        spin_unlock(&obj->oo_guard);
+        cfs_spin_unlock(&obj->oo_guard);
         mark_inode_dirty(inode);
         LINVRNT(osd_invariant(obj));
 }
@@ -1896,10 +1896,10 @@ static void osd_object_ref_del(const struct lu_env *env,
         LASSERT(osd_write_locked(env, obj));
         LASSERT(th != NULL);
 
-        spin_lock(&obj->oo_guard);
+        cfs_spin_lock(&obj->oo_guard);
         LASSERT(inode->i_nlink > 0);
         inode->i_nlink--;
-        spin_unlock(&obj->oo_guard);
+        cfs_spin_unlock(&obj->oo_guard);
         mark_inode_dirty(inode);
         LINVRNT(osd_invariant(obj));
 }
@@ -1996,9 +1996,9 @@ static int osd_xattr_del(const struct lu_env *env,
         *t = inode->i_ctime;
         rc = inode->i_op->removexattr(dentry, name);
         /* ctime should not be updated with server-side time. */
-        spin_lock(&obj->oo_guard);
+        cfs_spin_lock(&obj->oo_guard);
         inode->i_ctime = *t;
-        spin_unlock(&obj->oo_guard);
+        cfs_spin_unlock(&obj->oo_guard);
         mark_inode_dirty(inode);
         return rc;
 }
@@ -2045,9 +2045,9 @@ static struct obd_capa *osd_capa_get(const struct lu_env *env,
                 __u32 d[4], s[4];
 
                 s[0] = obj->oo_inode->i_uid;
-                get_random_bytes(&(s[1]), sizeof(__u32));
+                ll_get_random_bytes(&(s[1]), sizeof(__u32));
                 s[2] = obj->oo_inode->i_gid;
-                get_random_bytes(&(s[3]), sizeof(__u32));
+                ll_get_random_bytes(&(s[3]), sizeof(__u32));
                 rc = capa_encrypt_id(d, s, key->lk_key, CAPA_HMAC_KEY_MAX_LEN);
                 if (unlikely(rc))
                         RETURN(ERR_PTR(rc));
@@ -2073,9 +2073,9 @@ static struct obd_capa *osd_capa_get(const struct lu_env *env,
                 RETURN(oc);
         }
 
-        spin_lock(&capa_lock);
+        cfs_spin_lock(&capa_lock);
         *key = dev->od_capa_keys[1];
-        spin_unlock(&capa_lock);
+        cfs_spin_unlock(&capa_lock);
 
         capa->lc_keyid = key->lk_keyid;
         capa->lc_expiry = cfs_time_current_sec() + dev->od_capa_timeout;
@@ -2233,7 +2233,7 @@ static int osd_index_try(const struct lu_env *env, struct dt_object *dt,
                 OBD_ALLOC_PTR(dir);
                 if (dir != NULL) {
 
-                        spin_lock(&obj->oo_guard);
+                        cfs_spin_lock(&obj->oo_guard);
                         if (obj->oo_dir == NULL)
                                 obj->oo_dir = dir;
                         else
@@ -2241,12 +2241,12 @@ static int osd_index_try(const struct lu_env *env, struct dt_object *dt,
                                  * Concurrent thread allocated container data.
                                  */
                                 OBD_FREE_PTR(dir);
-                        spin_unlock(&obj->oo_guard);
+                        cfs_spin_unlock(&obj->oo_guard);
                         /*
                          * Now, that we have container data, serialize its
                          * initialization.
                          */
-                        down_write(&obj->oo_ext_idx_sem);
+                        cfs_down_write(&obj->oo_ext_idx_sem);
                         /*
                          * recheck under lock.
                          */
@@ -2254,7 +2254,7 @@ static int osd_index_try(const struct lu_env *env, struct dt_object *dt,
                                 result = osd_iam_container_init(env, obj, dir);
                         else
                                 result = 0;
-                        up_write(&obj->oo_ext_idx_sem);
+                        cfs_up_write(&obj->oo_ext_idx_sem);
                 } else
                         result = -ENOMEM;
         } else
@@ -2396,7 +2396,7 @@ static const struct dt_body_operations osd_body_ops = {
 /**
  *      delete a (key, value) pair from index \a dt specified by \a key
  *
- *      \param  dt_object      osd index object
+ *      \param  dt      osd index object
  *      \param  key     key for index
  *      \param  rec     record reference
  *      \param  handle  transaction handler
@@ -2478,8 +2478,8 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
         dentry = osd_child_dentry_get(env, obj,
                                       (char *)key, strlen((char *)key));
 
-        down_write(&obj->oo_ext_idx_sem);
-        bh = ldiskfs_find_entry(dentry, &de);
+        cfs_down_write(&obj->oo_ext_idx_sem);
+        bh = ll_ldiskfs_find_entry(dir, dentry, &de);
         if (bh) {
                 struct osd_thread_info *oti = osd_oti_get(env);
                 struct timespec *ctime = &oti->oti_time;
@@ -2490,16 +2490,16 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
                 rc = ldiskfs_delete_entry(oh->ot_handle,
                                 dir, de, bh);
                 /* xtime should not be updated with server-side time. */
-                spin_lock(&obj->oo_guard);
+                cfs_spin_lock(&obj->oo_guard);
                 dir->i_ctime = *ctime;
                 dir->i_mtime = *mtime;
-                spin_unlock(&obj->oo_guard);
+                cfs_spin_unlock(&obj->oo_guard);
                 mark_inode_dirty(dir);
                 brelse(bh);
         } else
                 rc = -ENOENT;
 
-        up_write(&obj->oo_ext_idx_sem);
+        cfs_up_write(&obj->oo_ext_idx_sem);
         LASSERT(osd_invariant(obj));
         RETURN(rc);
 }
@@ -2507,7 +2507,7 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
 /**
  *      Lookup index for \a key and copy record to \a rec.
  *
- *      \param  dt_object      osd index object
+ *      \param  dt      osd index object
  *      \param  key     key for index
  *      \param  rec     record reference
  *
@@ -2751,8 +2751,8 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
         dentry = osd_child_dentry_get(env, obj,
                                       (char *)key, strlen((char *)key));
 
-        down_read(&obj->oo_ext_idx_sem);
-        bh = ldiskfs_find_entry(dentry, &de);
+        cfs_down_read(&obj->oo_ext_idx_sem);
+        bh = ll_ldiskfs_find_entry(dir, dentry, &de);
         if (bh) {
                 ino = le32_to_cpu(de->inode);
                 brelse(bh);
@@ -2760,17 +2760,17 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
         } else
                 rc = -ENOENT;
 
-        up_read(&obj->oo_ext_idx_sem);
+        cfs_up_read(&obj->oo_ext_idx_sem);
         RETURN (rc);
 }
 
 /**
  * Find the osd object for given fid.
  *
- * \param fid, need to find the osd object having this fid
+ * \param fid need to find the osd object having this fid
  *
- * \retval osd_object, on success
- * \retval        -ve, on error
+ * \retval osd_object on success
+ * \retval        -ve on error
  */
 struct osd_object *osd_object_find(const struct lu_env *env,
                                    struct dt_object *dt,
@@ -2812,7 +2812,7 @@ struct osd_object *osd_object_find(const struct lu_env *env,
 /**
  * Put the osd object once done with it.
  *
- * \param obj, osd object that needs to be put
+ * \param obj osd object that needs to be put
  */
 static inline void osd_object_put(const struct lu_env *env,
                                   struct osd_object *obj)
@@ -2825,8 +2825,8 @@ static inline void osd_object_put(const struct lu_env *env,
  * It will add the directory entry.This entry is needed to
  * maintain name->fid mapping.
  *
- * \param key, it is key i.e. file entry to be inserted
- * \param rec, it is value of given key i.e. fid
+ * \param key it is key i.e. file entry to be inserted
+ * \param rec it is value of given key i.e. fid
  *
  * \retval   0, on success
  * \retval -ve, on error
@@ -2869,18 +2869,18 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
                 else
                         current->cap_effective &= ~CFS_CAP_SYS_RESOURCE_MASK;
 #endif
-                down_write(&obj->oo_ext_idx_sem);
+                cfs_down_write(&obj->oo_ext_idx_sem);
                 rc = osd_ea_add_rec(env, obj, child, name, th);
-                up_write(&obj->oo_ext_idx_sem);
+                cfs_up_write(&obj->oo_ext_idx_sem);
 #ifdef HAVE_QUOTA_SUPPORT
                 current->cap_effective = save;
 #endif
                 osd_object_put(env, child);
                 /* xtime should not be updated with server-side time. */
-                spin_lock(&obj->oo_guard);
+                cfs_spin_lock(&obj->oo_guard);
                 inode->i_ctime = *ctime;
                 inode->i_mtime = *mtime;
-                spin_unlock(&obj->oo_guard);
+                cfs_spin_unlock(&obj->oo_guard);
                 mark_inode_dirty(inode);
         } else {
                 rc = PTR_ERR(child);
@@ -3181,7 +3181,7 @@ static struct dt_it *osd_it_ea_init(const struct lu_env *env,
 /**
  * Destroy or finishes iterator context.
  *
- * \param di, struct osd_it_ea, iterator structure to be destroyed
+ * \param di iterator structure to be destroyed
  */
 static void osd_it_ea_fini(const struct lu_env *env, struct dt_it *di)
 {
@@ -3232,11 +3232,11 @@ static void osd_it_ea_put(const struct lu_env *env, struct dt_it *di)
  * iterator's in-memory data structure with required
  * information i.e. name, namelen, rec_size etc.
  *
- * \param buf, in which information to be filled in.
- * \param name, name of the file in given dir
+ * \param buf in which information to be filled in.
+ * \param name name of the file in given dir
  *
- * \retval 0, on success
- * \retval 1, on buffer full
+ * \retval 0 on success
+ * \retval 1 on buffer full
  */
 static int osd_ldiskfs_filldir(char *buf, const char *name, int namelen,
                                loff_t offset, __u64 ino,
@@ -3264,7 +3264,7 @@ static int osd_ldiskfs_filldir(char *buf, const char *name, int namelen,
         memcpy(ent->oied_name, name, namelen);
 
         it->oie_rd_dirent++;
-        it->oie_dirent = (void *) ent + size_round(sizeof(*ent) + namelen);
+        it->oie_dirent = (void *) ent + cfs_size_round(sizeof(*ent) + namelen);
         RETURN(0);
 }
 
@@ -3272,10 +3272,10 @@ static int osd_ldiskfs_filldir(char *buf, const char *name, int namelen,
  * Calls ->readdir() to load a directory entry at a time
  * and stored it in iterator's in-memory data structure.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
  *
- * \retval   0, on success
- * \retval -ve, on error
+ * \retval   0 on success
+ * \retval -ve on error
  */
 static int osd_ldiskfs_it_fill(const struct dt_it *di)
 {
@@ -3288,11 +3288,11 @@ static int osd_ldiskfs_it_fill(const struct dt_it *di)
         it->oie_dirent = it->oie_buf;
         it->oie_rd_dirent = 0;
 
-        down_read(&obj->oo_ext_idx_sem);
+        cfs_down_read(&obj->oo_ext_idx_sem);
         result = inode->i_fop->readdir(&it->oie_file, it,
                                        (filldir_t) osd_ldiskfs_filldir);
 
-        up_read(&obj->oo_ext_idx_sem);
+        cfs_up_read(&obj->oo_ext_idx_sem);
 
         if (it->oie_rd_dirent == 0) {
                 result = -EIO;
@@ -3309,11 +3309,11 @@ static int osd_ldiskfs_it_fill(const struct dt_it *di)
  * to load a directory entry at a time and stored it in
  * iterator's in-memory data structure.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
  *
- * \retval +ve, iterator reached to end
- * \retval   0, iterator not reached to end
- * \retval -ve, on error
+ * \retval +ve iterator reached to end
+ * \retval   0 iterator not reached to end
+ * \retval -ve on error
  */
 static int osd_it_ea_next(const struct lu_env *env, struct dt_it *di)
 {
@@ -3323,9 +3323,10 @@ static int osd_it_ea_next(const struct lu_env *env, struct dt_it *di)
         ENTRY;
 
         if (it->oie_it_dirent < it->oie_rd_dirent) {
-                it->oie_dirent = (void *) it->oie_dirent +
-                                 size_round(sizeof(struct osd_it_ea_dirent) +
-                                            it->oie_dirent->oied_namelen);
+                it->oie_dirent =
+                        (void *) it->oie_dirent +
+                        cfs_size_round(sizeof(struct osd_it_ea_dirent) +
+                                       it->oie_dirent->oied_namelen);
                 it->oie_it_dirent++;
                 RETURN(0);
         } else {
@@ -3341,7 +3342,7 @@ static int osd_it_ea_next(const struct lu_env *env, struct dt_it *di)
 /**
  * Returns the key at current position from iterator's in memory structure.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
  *
  * \retval key i.e. struct dt_key on success
  */
@@ -3356,7 +3357,7 @@ static struct dt_key *osd_it_ea_key(const struct lu_env *env,
 /**
  * Returns the key's size at current position from iterator's in memory structure.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
  *
  * \retval key_size i.e. struct dt_key on success
  */
@@ -3372,12 +3373,12 @@ static int osd_it_ea_key_size(const struct lu_env *env, const struct dt_it *di)
  * Returns the value (i.e. fid/igif) at current position from iterator's
  * in memory structure.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
- * \param attr, attr requested for dirent.
- * \param lde, lustre dirent
+ * \param di struct osd_it_ea, iterator's in memory structure
+ * \param attr attr requested for dirent.
+ * \param lde lustre dirent
  *
- * \retval   0, no error and \param lde has correct lustre dirent.
- * \retval -ve, on error
+ * \retval   0 no error and \param lde has correct lustre dirent.
+ * \retval -ve on error
  */
 static inline int osd_it_ea_rec(const struct lu_env *env,
                                 const struct dt_it *di,
@@ -3407,7 +3408,7 @@ static inline int osd_it_ea_rec(const struct lu_env *env,
  * Returns a cookie for current position of the iterator head, so that
  * user can use this cookie to load/start the iterator next time.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
  *
  * \retval cookie for current position, on success
  */
@@ -3423,10 +3424,10 @@ static __u64 osd_it_ea_store(const struct lu_env *env, const struct dt_it *di)
  * to load a directory entry at a time and stored it i inn,
  * in iterator's in-memory data structure.
  *
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di struct osd_it_ea, iterator's in memory structure
  *
- * \retval +ve, on success
- * \retval -ve, on error
+ * \retval +ve on success
+ * \retval -ve on error
  */
 static int osd_it_ea_load(const struct lu_env *env,
                           const struct dt_it *di, __u64 hash)
@@ -3654,7 +3655,7 @@ static struct lu_device *osd_device_alloc(const struct lu_env *env,
                         l = osd2lu_dev(o);
                         l->ld_ops = &osd_lu_ops;
                         o->od_dt_dev.dd_ops = &osd_dt_ops;
-                        spin_lock_init(&o->od_osfs_lock);
+                        cfs_spin_lock_init(&o->od_osfs_lock);
                         o->od_osfs_age = cfs_time_shift_64(-1000);
                         o->od_capa_hash = init_capa_hash();
                         if (o->od_capa_hash == NULL) {
@@ -3707,10 +3708,6 @@ static int osd_process_config(const struct lu_env *env,
 static int osd_recovery_complete(const struct lu_env *env,
                                  struct lu_device *d)
 {
-        struct osd_device *o = osd_dev(d);
-        ENTRY;
-        /* TODO: orphans handling */
-        ldiskfs_orphan_cleanup(osd_sb(o), LDISKFS_SB(osd_sb(o))->s_es);
         RETURN(0);
 }