fld->lsf_control_exp = NULL;
- /* Insert reserved sequence number of ".lustre" into fld cache. */
if (lsr_flags == LU_SEQ_RANGE_MDT) {
- range.lsr_start = FID_SEQ_DOT_LUSTRE;
+ /* Insert reserved sequence of "ROOT" and ".lustre"
+ * into fld cache. */
+ range.lsr_start = FID_SEQ_LOCAL_FILE;
range.lsr_end = FID_SEQ_DOT_LUSTRE + 1;
range.lsr_index = 0;
range.lsr_flags = lsr_flags;
}
/**
- * Build igif from the inode number/generation.
- */
-#define LU_IGIF_BUILD(fid, ino, gen) \
-do { \
- fid->f_seq = ino; \
- fid->f_oid = gen; \
- fid->f_ver = 0; \
-} while(0)
-static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen)
-{
- LU_IGIF_BUILD(fid, ino, gen);
- LASSERT(fid_is_igif(fid));
-}
-
-/**
* Get inode generation from a igif.
* \param fid a igif to get inode generation from.
* \return inode generation for the igif.
return fid_oid(fid);
}
+/**
+ * Build igif from the inode number/generation.
+ */
+static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen)
+{
+ fid->f_seq = ino;
+ fid->f_oid = gen;
+ fid->f_ver = 0;
+}
+
/*
* Fids are transmitted across network (in the sender byte-ordering),
* and stored on disk in big-endian order.
fid->f_ver = 0;
}
+static inline int fid_is_root(const struct lu_fid *fid)
+{
+ return unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE &&
+ fid_oid(fid) == MDD_ROOT_INDEX_OID);
+}
+
+static inline int fid_is_dot_lustre(const struct lu_fid *fid)
+{
+ return unlikely(fid_seq(fid) == FID_SEQ_DOT_LUSTRE &&
+ fid_oid(fid) == FID_OID_DOT_LUSTRE);
+}
+
static inline int fid_is_otable_it(const struct lu_fid *fid)
{
return unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE &&
fid_seq(fid) == FID_SEQ_QUOTA_GLB;
}
+static inline int fid_is_client_mdt_visible(const struct lu_fid *fid)
+{
+ const __u64 seq = fid_seq(fid);
+
+ /* Here, we cannot distinguish whether the normal FID is for OST
+ * object or not. It is caller's duty to check more if needed. */
+ return (!fid_is_last_id(fid) &&
+ (fid_seq_is_norm(seq) || fid_seq_is_igif(seq))) ||
+ fid_is_root(fid) || fid_is_dot_lustre(fid);
+}
+
+static inline int fid_is_client_visible(const struct lu_fid *fid)
+{
+ return fid_is_client_mdt_visible(fid) || fid_is_idif(fid);
+}
+
static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq)
{
if (fid_seq_is_mdt0(seq)) {
const struct lu_name *lname, struct lu_fid *f,
struct md_op_spec *spec)
{
- if (strcmp(lname->ln_name, mdd_obf_dir_name) == 0)
- *f = LU_OBF_FID;
- else
- return -ENOENT;
+ if (strcmp(lname->ln_name, mdd_obf_dir_name) == 0) {
+ *f = LU_OBF_FID;
+ return 0;
+ }
- return 0;
+ return -ENOENT;
}
static mdl_mode_t dot_lustre_mdd_lock_mode(const struct lu_env *env,
struct dt_object *dt_dot_lustre;
struct lu_fid *fid = &mdd_env_info(env)->mti_fid;
int rc;
+ ENTRY;
rc = create_dot_lustre_dir(env, m);
if (rc)
RETURN(rc);
}
+static inline int mdd_declare_links_del(const struct lu_env *env,
+ struct mdd_object *c,
+ struct thandle *handle)
+{
+ int rc = 0;
+
+ /* For directory, the linkEA will be removed together with the object. */
+ if (!S_ISDIR(mdd_object_type(c)))
+ rc = mdd_declare_links_add(env, c, handle);
+
+ return rc;
+}
+
static int mdd_declare_unlink(const struct lu_env *env, struct mdd_device *mdd,
struct mdd_object *p, struct mdd_object *c,
const struct lu_name *name, struct md_attr *ma,
if (rc)
return rc;
- rc = mdd_declare_links_add(env, c, handle);
- if (rc)
- return rc;
+ rc = mdd_declare_links_del(env, c, handle);
+ if (rc != 0)
+ return rc;
- rc = mdd_declare_changelog_store(env, mdd, name, handle);
+ rc = mdd_declare_changelog_store(env, mdd, name, handle);
- return rc;
+ return rc;
}
static int mdd_unlink(const struct lu_env *env, struct md_object *pobj,
mdd_pdo_write_unlock(env, mdd_pobj, dlh);
out_trans:
- if (rc == 0)
+ if (rc == 0 && fid_is_client_mdt_visible(mdo2fid(son)))
rc = mdd_changelog_ns_store(env, mdd,
S_ISDIR(attr->la_mode) ? CL_MKDIR :
S_ISREG(attr->la_mode) ? CL_CREATE :
if (!fid_is_sane(&fp->gf_fid))
RETURN(-EINVAL);
- if (!fid_is_norm(&fp->gf_fid) && !fid_is_igif(&fp->gf_fid)) {
+ if (!fid_is_client_mdt_visible(&fp->gf_fid)) {
CWARN("%s: "DFID" is invalid, sequence should be "
">= "LPX64"\n", obd->obd_name,
PFID(&fp->gf_fid), (__u64)FID_SEQ_NORMAL);
MODULES := osd_ldiskfs
-osd_ldiskfs-objs := osd_handler.o osd_oi.o osd_igif.o osd_lproc.o osd_iam.o \
+osd_ldiskfs-objs := osd_handler.o osd_oi.o osd_lproc.o osd_iam.o \
osd_iam_lfix.o osd_iam_lvar.o osd_io.o osd_compat.o \
osd_scrub.o osd_quota.o osd_quota_fmt.o
endif
MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
-EXTRA_DIST := $(osd_ldiskfs-objs:%.o=%.c) osd_internal.h osd_oi.h osd_igif.h \
+EXTRA_DIST := $(osd_ldiskfs-objs:%.o=%.c) osd_internal.h osd_oi.h \
osd_iam.h osd_scrub.h osd_quota_fmt.h
#include <obd_support.h>
/* struct ptlrpc_thread */
#include <lustre_net.h>
-
-/* fid_is_local() */
#include <lustre_fid.h>
#include "osd_internal.h"
-#include "osd_igif.h"
/* llo_* api support */
#include <md_object.h>
if (rc == 0) {
*fid = lma->lma_self_fid;
} else if (rc == -ENODATA) {
- LU_IGIF_BUILD(fid, inode->i_ino, inode->i_generation);
+ if (unlikely(inode == osd_sb(dev)->s_root->d_inode))
+ lu_local_obj_fid(fid, OSD_FS_ROOT_OID);
+ else
+ lu_igif_build(fid, inode->i_ino, inode->i_generation);
} else {
iput(inode);
inode = ERR_PTR(rc);
LINVRNT(osd_invariant(obj));
+ if (fid_is_otable_it(&l->lo_header->loh_fid)) {
+ obj->oo_dt.do_ops = &osd_obj_otable_it_ops;
+ l->lo_header->loh_attr |= LOHA_EXISTS;
+ return 0;
+ }
+
result = osd_fid_lookup(env, obj, lu_object_fid(l), conf);
obj->oo_dt.do_body_ops = &osd_body_ops_new;
- if (result == 0) {
- if (obj->oo_inode != NULL) {
- osd_object_init0(obj);
- } else if (fid_is_otable_it(&l->lo_header->loh_fid)) {
- obj->oo_dt.do_ops = &osd_obj_otable_it_ops;
- /* LFSCK iterator object is special without inode */
- l->lo_header->loh_attr |= LOHA_EXISTS;
- }
- }
+ if (result == 0 && obj->oo_inode != NULL)
+ osd_object_init0(obj);
+
LINVRNT(osd_invariant(obj));
return result;
}
* its inmemory API.
*/
void osd_get_ldiskfs_dirent_param(struct ldiskfs_dentry_param *param,
- const struct dt_rec *fid)
+ const struct dt_rec *fid)
{
- param->edp_magic = LDISKFS_LUFID_MAGIC;
- param->edp_len = sizeof(struct lu_fid) + 1;
+ /* XXX: replace the check with "!fid_is_client_mdt_visible()"
+ * when FID in OI file introduced for local object. */
+ if (!fid_is_norm((const struct lu_fid *)fid) &&
+ !fid_is_igif((const struct lu_fid *)fid)) {
+ param->edp_magic = 0;
+ return;
+ }
- fid_cpu_to_be((struct lu_fid *)param->edp_data,
- (struct lu_fid *)fid);
+ param->edp_magic = LDISKFS_LUFID_MAGIC;
+ param->edp_len = sizeof(struct lu_fid) + 1;
+ fid_cpu_to_be((struct lu_fid *)param->edp_data, (struct lu_fid *)fid);
}
/**
} else if (unlikely(feat == &dt_otable_features)) {
dt->do_index_ops = &osd_otable_ops;
return 0;
- } else if (feat == &dt_acct_features) {
+ } else if (unlikely(feat == &dt_acct_features)) {
dt->do_index_ops = &osd_acct_index_ops;
result = 0;
skip_iam = 1;
oth = container_of(th, struct osd_thandle, ot_super);
LASSERT(oth->ot_handle != NULL);
LASSERT(oth->ot_handle->h_transaction != NULL);
-
- child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name));
-
- /* XXX: remove fid_is_igif() check here.
- * IGIF check is just to handle insertion of .. when it is 'ROOT',
- * it is IGIF now but needs FID in dir entry as well for readdir
- * to work.
- * LU-838 should fix that and remove fid_is_igif() check */
- if (fid_is_igif((struct lu_fid *)fid) ||
- fid_is_norm((struct lu_fid *)fid)) {
- ldp = (struct ldiskfs_dentry_param *)info->oti_ldp;
- osd_get_ldiskfs_dirent_param(ldp, fid);
- child->d_fsdata = (void *)ldp;
- } else {
- child->d_fsdata = NULL;
- }
LASSERT(pobj->oo_inode);
+
+ ldp = (struct ldiskfs_dentry_param *)info->oti_ldp;
+ if (unlikely(pobj->oo_inode ==
+ osd_sb(osd_obj2dev(pobj))->s_root->d_inode))
+ ldp->edp_magic = 0;
+ else
+ osd_get_ldiskfs_dirent_param(ldp, fid);
+ child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name));
+ child->d_fsdata = (void *)ldp;
ll_vfs_dq_init(pobj->oo_inode);
- rc = osd_ldiskfs_add_entry(oth->ot_handle, child, cinode, hlock);
+ rc = osd_ldiskfs_add_entry(oth->ot_handle, child, cinode, hlock);
- RETURN(rc);
+ RETURN(rc);
}
/**
result = 0;
}
} else if(strcmp(name, dotdot) == 0) {
- dot_ldp = (struct ldiskfs_dentry_param *)info->oti_ldp;
- dot_dot_ldp = (struct ldiskfs_dentry_param *)info->oti_ldp2;
-
- if (!dir->oo_compat_dot_created)
- return -EINVAL;
- if (!fid_is_igif((struct lu_fid *)dot_fid)) {
- osd_get_ldiskfs_dirent_param(dot_ldp, dot_fid);
- osd_get_ldiskfs_dirent_param(dot_dot_ldp, dot_dot_fid);
- } else {
- dot_ldp = NULL;
- dot_dot_ldp = NULL;
- }
- /* in case of rename, dotdot is already created */
- if (dir->oo_compat_dotdot_created) {
- return __osd_ea_add_rec(info, dir, parent_dir, name,
- dot_dot_fid, NULL, th);
- }
-
- result = ldiskfs_add_dot_dotdot(oth->ot_handle, parent_dir,
- inode, dot_ldp, dot_dot_ldp);
- if (result == 0)
- dir->oo_compat_dotdot_created = 1;
- }
+ if (!dir->oo_compat_dot_created)
+ return -EINVAL;
+
+ dot_dot_ldp = (struct ldiskfs_dentry_param *)info->oti_ldp2;
+ osd_get_ldiskfs_dirent_param(dot_dot_ldp, dot_dot_fid);
+ /* in case of rename, dotdot is already created */
+ if (dir->oo_compat_dotdot_created)
+ return __osd_ea_add_rec(info, dir, parent_dir, name,
+ dot_dot_fid, NULL, th);
+
+ dot_ldp = (struct ldiskfs_dentry_param *)info->oti_ldp;
+ dot_ldp->edp_magic = 0;
+ result = ldiskfs_add_dot_dotdot(oth->ot_handle, parent_dir,
+ inode, dot_ldp, dot_dot_ldp);
+ if (result == 0)
+ dir->oo_compat_dotdot_created = 1;
+ }
- return result;
+ return result;
}
struct htree_lock *hlock = NULL;
int ino;
int rc;
+ ENTRY;
LASSERT(dir->i_op != NULL && dir->i_op->lookup != NULL);
unsigned d_type)
{
struct osd_it_ea *it = (struct osd_it_ea *)buf;
+ struct osd_object *obj = it->oie_obj;
struct osd_it_ea_dirent *ent = it->oie_dirent;
struct lu_fid *fid = &ent->oied_fid;
struct osd_fid_pack *rec;
OSD_IT_EA_BUFSIZE)
RETURN(1);
- if (d_type & LDISKFS_DIRENT_LUFID) {
- rec = (struct osd_fid_pack*) (name + namelen + 1);
-
- if (osd_fid_unpack(fid, rec) != 0)
- fid_zero(fid);
+ /* "." is just the object itself. */
+ if (namelen == 1 && name[0] == '.') {
+ *fid = obj->oo_dt.do_lu.lo_header->loh_fid;
+ } else if (d_type & LDISKFS_DIRENT_LUFID) {
+ rec = (struct osd_fid_pack*) (name + namelen + 1);
+ if (osd_fid_unpack(fid, rec) != 0)
+ fid_zero(fid);
+ } else {
+ fid_zero(fid);
+ }
+ d_type &= ~LDISKFS_DIRENT_LUFID;
- d_type &= ~LDISKFS_DIRENT_LUFID;
- } else {
- fid_zero(fid);
- }
+ /* NOT export local root. */
+ if (unlikely(osd_sb(osd_obj2dev(obj))->s_root->d_inode->i_ino == ino)) {
+ ino = obj->oo_inode->i_ino;
+ *fid = obj->oo_dt.do_lu.lo_header->loh_fid;
+ }
ent->oied_ino = ino;
ent->oied_off = offset;
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/osd/osd_igif.c
- *
- * igif (compatibility fids) support
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <linux/module.h>
-
-/* LUSTRE_VERSION_CODE */
-#include <lustre_ver.h>
-
-/* struct osd_inode_id */
-#include "osd_oi.h"
-#include "osd_igif.h"
-#include "osd_internal.h"
-
-/* fid stuff */
-#include <lustre/lustre_idl.h>
-
-void lu_igif_to_id(const struct lu_fid *fid, struct osd_inode_id *id)
-{
- LASSERT(fid_is_igif(fid));
- osd_id_gen(id, lu_igif_ino(fid), lu_igif_gen(fid));
-}
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/osd/osd_igif.h
- *
- * igif (compatibility fids) support
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef _OSD_IGIF_H
-#define _OSD_IGIF_H
-
-#if defined(__KERNEL__)
-
-struct lu_fid;
-struct osd_inode_id;
-
-void lu_igif_to_id(const struct lu_fid *fid, struct osd_inode_id *id);
-void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen);
-
-#endif /* __KERNEL__ */
-#endif /* _OSD_IGIF_H */
{
LASSERTF(!fid_is_idif(fid), DFID"\n", PFID(fid));
LASSERTF(!fid_is_last_id(fid), DFID"\n", PFID(fid));
- LASSERTF(!fid_is_igif(fid), DFID"\n", PFID(fid));
LASSERT(osd->od_oi_table != NULL && osd->od_oi_count >= 1);
/* It can work even od_oi_count equals to 1 although it's unexpected,
* the only reason we set it to 1 is for performance measurement */
#include "osd_oi.h"
/* osd_lookup(), struct osd_thread_info */
#include "osd_internal.h"
-#include "osd_igif.h"
#include "osd_scrub.h"
static unsigned int osd_oi_count = OSD_OI_FID_NR;
/* FIXME: actually for all of the OST object */
rc = osd_obj_map_lookup(info, osd, fid, id);
} else if (fid_is_igif(fid)) {
- lu_igif_to_id(fid, id);
+ osd_id_gen(id, lu_igif_ino(fid), lu_igif_gen(fid));
} else if (fid_is_fs_root(fid)) {
osd_id_gen(id, osd_sb(osd)->s_root->d_inode->i_ino,
osd_sb(osd)->s_root->d_inode->i_generation);
if (sf->sf_pos_last_checkpoint != 0)
sf->sf_pos_latest_start = sf->sf_pos_last_checkpoint + 1;
else
- sf->sf_pos_latest_start = LDISKFS_FIRST_INO(osd_sb(dev));
+ sf->sf_pos_latest_start = LDISKFS_FIRST_INO(osd_sb(dev)) + 1;
scrub->os_pos_current = sf->sf_pos_latest_start;
sf->sf_status = SS_SCANNING;
if (sf->sf_pos_last_checkpoint != 0)
scrub->os_pos_current = sf->sf_pos_last_checkpoint + 1;
else
- scrub->os_pos_current = LDISKFS_FIRST_INO(sb);
+ scrub->os_pos_current = LDISKFS_FIRST_INO(sb) + 1;
if (dirty != 0) {
rc = osd_scrub_file_store(scrub);
if (it->ooi_user_ready)
return 0;
- if (ooc->ooc_pos_preload < LDISKFS_FIRST_INO(osd_sb(dev)))
- ooc->ooc_pos_preload = LDISKFS_FIRST_INO(osd_sb(dev));
+ if (ooc->ooc_pos_preload <= LDISKFS_FIRST_INO(osd_sb(dev)))
+ ooc->ooc_pos_preload = LDISKFS_FIRST_INO(osd_sb(dev)) + 1;
it->ooi_user_ready = 1;
if (!scrub->os_full_speed)
cfs_waitq_broadcast(&scrub->os_thread.t_ctl_waitq);
LASSERT(osd_invariant(obj));
+ if (fid_is_otable_it(&l->lo_header->loh_fid)) {
+ obj->oo_dt.do_ops = &osd_obj_otable_it_ops;
+ l->lo_header->loh_attr |= LOHA_EXISTS;
+ RETURN(0);
+ }
+
rc = osd_fid_lookup(env, osd, lu_object_fid(l), &oid);
if (rc == 0) {
LASSERT(obj->oo_db == NULL);
CERROR("%s: lookup "DFID"/"LPX64" failed: rc = %d\n",
osd->od_svname, PFID(lu_object_fid(l)), oid, rc);
}
- } else if (rc == -ENOENT) {
- if (fid_is_otable_it(&l->lo_header->loh_fid)) {
- obj->oo_dt.do_ops = &osd_obj_otable_it_ops;
- /* LFSCK iterator object is special without inode */
- l->lo_header->loh_attr |= LOHA_EXISTS;
- }
- rc = 0;
}
LASSERT(osd_invariant(obj));
RETURN(rc);