Whamcloud - gitweb
LU-14651 llite: extend inode methods with user namespace arg
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_compat.c
index 2150f28..23e623a 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/osd/osd_compat.c
  *
@@ -59,7 +58,6 @@ static void osd_push_ctxt(const struct osd_device *dev,
        OBD_SET_CTXT_MAGIC(newctxt);
        newctxt->pwdmnt = dev->od_mnt;
        newctxt->pwd = dev->od_mnt->mnt_root;
-       newctxt->fs = KERNEL_DS;
        newctxt->umask = current_umask();
        newctxt->dt = NULL;
 
@@ -202,7 +200,7 @@ simple_mkdir(const struct lu_env *env, struct osd_device *osd,
                RETURN(dchild);
        }
 
-       err = vfs_mkdir(dir->d_inode, dchild, mode);
+       err = vfs_mkdir(&init_user_ns, dir->d_inode, dchild, mode);
        if (err)
                GOTO(out_err, err);
 
@@ -546,8 +544,8 @@ static void osd_seq_free(struct osd_obj_seq *osd_seq)
                        if (osd_seq->oos_dirs[j])
                                dput(osd_seq->oos_dirs[j]);
                }
-               OBD_FREE(osd_seq->oos_dirs,
-                        sizeof(struct dentry *) * osd_seq->oos_subdir_count);
+               OBD_FREE_PTR_ARRAY(osd_seq->oos_dirs,
+                                  osd_seq->oos_subdir_count);
        }
 
        if (osd_seq->oos_root)
@@ -611,10 +609,8 @@ static int osd_index_backup_dir_init(const struct lu_env *env,
 
 static void osd_index_backup_dir_fini(struct osd_device *dev)
 {
-       if (dev->od_index_backup_inode) {
-               iput(dev->od_index_backup_inode);
-               dev->od_index_backup_inode = NULL;
-       }
+       iput(dev->od_index_backup_inode);
+       dev->od_index_backup_inode = NULL;
 }
 
 int osd_obj_map_init(const struct lu_env *env, struct osd_device *dev)
@@ -830,10 +826,9 @@ out:
        return rc;
 }
 
-static int osd_obj_del_entry(struct osd_thread_info *info,
-                            struct osd_device *osd,
-                            struct dentry *dird, char *name,
-                            handle_t *th)
+int osd_obj_del_entry(struct osd_thread_info *info, struct osd_device *osd,
+                     struct dentry *dird, char *name, int namelen,
+                     handle_t *th)
 {
        struct ldiskfs_dir_entry_2 *de;
        struct buffer_head *bh;
@@ -849,7 +844,7 @@ static int osd_obj_del_entry(struct osd_thread_info *info,
        child = &info->oti_child_dentry;
        child->d_name.hash = 0;
        child->d_name.name = name;
-       child->d_name.len = strlen(name);
+       child->d_name.len = namelen;
        child->d_parent = dird;
        child->d_inode = NULL;
 
@@ -932,15 +927,6 @@ static inline void osd_seq_name(char *seq_name, size_t name_size, u64 seq)
                 fid_seq_is_idif(seq) ? 0 : seq);
 }
 
-static inline void osd_oid_name(char *name, size_t name_size,
-                               const struct lu_fid *fid, u64 id)
-{
-       snprintf(name, name_size,
-                (fid_seq_is_rsvd(fid_seq(fid)) ||
-                 fid_seq_is_mdt0(fid_seq(fid)) ||
-                 fid_seq_is_idif(fid_seq(fid))) ? "%llu" : "%llx", id);
-}
-
 /* external locking is required */
 static int osd_seq_load_locked(struct osd_thread_info *info,
                               struct osd_device *osd,
@@ -972,8 +958,7 @@ static int osd_seq_load_locked(struct osd_thread_info *info,
        osd_seq->oos_root = seq_dir;
 
        LASSERT(osd_seq->oos_dirs == NULL);
-       OBD_ALLOC(osd_seq->oos_dirs,
-                 sizeof(seq_dir) * osd_seq->oos_subdir_count);
+       OBD_ALLOC_PTR_ARRAY(osd_seq->oos_dirs, osd_seq->oos_subdir_count);
        if (osd_seq->oos_dirs == NULL)
                GOTO(out_put, rc = -ENOMEM);
 
@@ -1000,8 +985,8 @@ out_free:
                        if (osd_seq->oos_dirs[i] != NULL)
                                dput(osd_seq->oos_dirs[i]);
                }
-               OBD_FREE(osd_seq->oos_dirs,
-                        sizeof(seq_dir) * osd_seq->oos_subdir_count);
+               OBD_FREE_PTR_ARRAY(osd_seq->oos_dirs,
+                                  osd_seq->oos_subdir_count);
 out_put:
                dput(seq_dir);
                osd_seq->oos_root = NULL;
@@ -1010,8 +995,8 @@ out_err:
        RETURN(rc);
 }
 
-static struct osd_obj_seq *osd_seq_load(struct osd_thread_info *info,
-                                       struct osd_device *osd, u64 seq)
+struct osd_obj_seq *osd_seq_load(struct osd_thread_info *info,
+                                struct osd_device *osd, u64 seq)
 {
        struct osd_obj_map *map;
        struct osd_obj_seq *osd_seq;
@@ -1205,7 +1190,7 @@ int osd_obj_map_delete(struct osd_thread_info *info, struct osd_device *osd,
        LASSERT(d);
 
        osd_oid_name(name, sizeof(name), fid, ostid_id(ostid));
-       rc = osd_obj_del_entry(info, osd, d, name, th);
+       rc = osd_obj_del_entry(info, osd, d, name, strlen(name), th);
 cleanup:
        RETURN(rc);
 }
@@ -1328,7 +1313,7 @@ int osd_obj_map_recover(struct osd_thread_info *info,
                /* If the src object has never been modified, then remove it. */
                if (inode->i_size == 0 && inode->i_mode & S_ISUID &&
                    inode->i_mode & S_ISGID) {
-                       rc = ll_vfs_unlink(src_parent, src_child);
+                       rc = vfs_unlink(&init_user_ns, src_parent, src_child);
                        if (unlikely(rc == -ENOENT))
                                rc = 0;
                }