GOTO(out_up, dchild);
}
- err = ll_vfs_mkdir(dir->d_inode, dchild, mnt, mode);
+ err = vfs_mkdir(dir->d_inode, dchild, mode);
if (err)
GOTO(out_err, err);
LASSERT(dev->od_fsops);
osd_push_ctxt(dev, &new, &save);
- d = simple_mkdir(rootd, dev->od_mnt, "O", 0755, 1);
+ d = ll_lookup_one_len("O", rootd, strlen("O"));
if (IS_ERR(d))
GOTO(cleanup, rc = PTR_ERR(d));
+ if (d->d_inode == NULL) {
+ dput(d);
+ /* The lookup() may be called again inside simple_mkdir().
+ * Since the repeated lookup() only be called for "/O" at
+ * mount time, it will not affect the whole performance. */
+ d = simple_mkdir(rootd, dev->od_mnt, "O", 0755, 1);
+ if (IS_ERR(d))
+ GOTO(cleanup, rc = PTR_ERR(d));
+
+ /* It is quite probably that the device is new formatted. */
+ dev->od_maybe_new = 1;
+ }
inode = d->d_inode;
ldiskfs_set_inode_state(inode, LDISKFS_STATE_LUSTRE_NO_OI);
const struct osd_inode_id *id,
struct thandle *th)
{
- struct osd_thandle *oh;
- struct dentry *child;
- struct inode *inode;
- int rc;
+ struct osd_thandle *oh;
+ struct dentry *child;
+ struct inode *inode;
+ int rc;
- ENTRY;
+ ENTRY;
+
+ if (OBD_FAIL_CHECK(OBD_FAIL_OSD_COMPAT_NO_ENTRY))
+ RETURN(0);
- oh = container_of(th, struct osd_thandle, ot_super);
- LASSERT(oh->ot_handle != NULL);
- LASSERT(oh->ot_handle->h_transaction != NULL);
+ oh = container_of(th, struct osd_thandle, ot_super);
+ LASSERT(oh->ot_handle != NULL);
+ LASSERT(oh->ot_handle->h_transaction != NULL);
- inode = &info->oti_inode;
- inode->i_sb = osd_sb(osd);
+ inode = &info->oti_inode;
+ inode->i_sb = osd_sb(osd);
osd_id_to_inode(inode, id);
inode->i_mode = S_IFREG; /* for type in ldiskfs dir entry */
- child = &info->oti_child_dentry;
- child->d_name.hash = 0;
- child->d_name.name = name;
- child->d_name.len = strlen(name);
- child->d_parent = dir;
- child->d_inode = inode;
+ child = &info->oti_child_dentry;
+ child->d_name.hash = 0;
+ child->d_name.name = name;
+ child->d_name.len = strlen(name);
+ child->d_parent = dir;
+ child->d_inode = inode;
if (OBD_FAIL_CHECK(OBD_FAIL_OSD_COMPAT_INVALID_ENTRY))
inode->i_ino++;
RETURN(rc);
}
+int osd_obj_map_recover(struct osd_thread_info *info,
+ struct osd_device *osd,
+ struct inode *src_parent,
+ struct dentry *src_child,
+ const struct lu_fid *fid)
+{
+ struct osd_obj_seq *osd_seq;
+ struct dentry *tgt_parent;
+ struct dentry *tgt_child = &info->oti_child_dentry;
+ struct inode *dir;
+ struct inode *inode = src_child->d_inode;
+ struct ost_id *ostid = &info->oti_ostid;
+ handle_t *jh;
+ struct ldiskfs_dir_entry_2 *de;
+ struct buffer_head *bh;
+ char name[32];
+ int dirn;
+ int rc = 0;
+ ENTRY;
+
+ if (fid_is_last_id(fid)) {
+ osd_seq = osd_seq_load(info, osd, fid_seq(fid));
+ if (IS_ERR(osd_seq))
+ RETURN(PTR_ERR(osd_seq));
+
+ tgt_parent = osd_seq->oos_root;
+ tgt_child->d_name.name = "LAST_ID";
+ tgt_child->d_name.len = strlen("LAST_ID");
+ } else {
+ fid_to_ostid(fid, ostid);
+ osd_seq = osd_seq_load(info, osd, ostid_seq(ostid));
+ if (IS_ERR(osd_seq))
+ RETURN(PTR_ERR(osd_seq));
+
+ dirn = ostid_id(ostid) & (osd_seq->oos_subdir_count - 1);
+ tgt_parent = osd_seq->oos_dirs[dirn];
+ osd_oid_name(name, sizeof(name), fid, ostid_id(ostid));
+ tgt_child->d_name.name = name;
+ tgt_child->d_name.len = strlen(name);
+ }
+ LASSERT(tgt_parent != NULL);
+
+ dir = tgt_parent->d_inode;
+ tgt_child->d_name.hash = 0;
+ tgt_child->d_parent = tgt_parent;
+ tgt_child->d_inode = inode;
+
+ /* The non-initialized src_child may be destroyed. */
+ jh = ldiskfs_journal_start_sb(osd_sb(osd),
+ osd_dto_credits_noquota[DTO_INDEX_DELETE] +
+ osd_dto_credits_noquota[DTO_INDEX_INSERT] +
+ osd_dto_credits_noquota[DTO_OBJECT_DELETE]);
+ if (IS_ERR(jh))
+ RETURN(PTR_ERR(jh));
+
+ ll_vfs_dq_init(src_parent);
+ ll_vfs_dq_init(dir);
+
+ mutex_lock(&src_parent->i_mutex);
+ mutex_lock(&dir->i_mutex);
+ bh = osd_ldiskfs_find_entry(dir, tgt_child, &de, NULL);
+ if (bh != NULL) {
+ /* XXX: If some other object occupied the same slot. And If such
+ * inode is zero-sized and with SUID+SGID, then means it is
+ * a new created one. Maybe we can remove it and insert the
+ * original one back to the /O/<seq>/d<x>. But there are
+ * something to be considered:
+ *
+ * 1) The OST-object under /lost+found has crashed LMA.
+ * So it should not conflict with the current one.
+ *
+ * 2) There are race conditions that: someone may just want
+ * to modify the current one. Even if the OI scrub takes
+ * the object lock when remove the current one, it still
+ * cause the modification to be lost becasue the target
+ * has been removed when the RPC service thread waiting
+ * for the lock.
+ *
+ * So keep it there before we have suitable solution. */
+ brelse(bh);
+
+ mutex_unlock(&dir->i_mutex);
+ mutex_unlock(&src_parent->i_mutex);
+
+ rc = -EEXIST;
+ /* 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 = vfs_unlink(src_parent, src_child);
+ ldiskfs_journal_stop(jh);
+ RETURN(rc);
+ }
+
+ bh = osd_ldiskfs_find_entry(src_parent, src_child, &de, NULL);
+ if (unlikely(bh == NULL))
+ GOTO(unlock, rc = -ENOENT);
+
+ rc = ldiskfs_delete_entry(jh, src_parent, de, bh);
+ brelse(bh);
+ if (rc != 0)
+ GOTO(unlock, rc);
+
+ rc = osd_ldiskfs_add_entry(jh, tgt_child, inode, NULL);
+
+ GOTO(unlock, rc);
+
+unlock:
+ mutex_unlock(&dir->i_mutex);
+ mutex_unlock(&src_parent->i_mutex);
+ ldiskfs_journal_stop(jh);
+ return rc;
+}
+
static struct dentry *
osd_object_spec_find(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, char **name)