EXPORT_SYMBOL(seq_mgr_read);
/* manager functionality stuff */
-int seq_mgr_alloc(const struct lu_context *ctx, struct lu_seq_mgr *mgr,
+int seq_mgr_alloc(const struct lu_context *ctx,
+ struct lu_seq_mgr *mgr,
__u64 *seq)
{
- int rc = 0;
+ int rc;
ENTRY;
LASSERT(mgr != NULL);
/* set seq range */
mgr->m_seq_last = mgr->m_seq + LUSTRE_SEQ_RANGE;
+
/* allocate next seq after root one */
mgr->m_seq += LUSTRE_ROOT_FID_SEQ + 1;
LUSTRE_SEQ_RANGE = 1000,
/* initial fid id value */
- LUSTRE_FID_INIT_OID = 1UL,
-
- /* shift of version component */
- LUSTRE_FID_VER_SHIFT = (sizeof(((struct lu_fid *)0)->f_ver) * 8)
+ LUSTRE_FID_INIT_OID = 1UL
};
/* get object sequence */
return fid->f_ver;
}
-/* get complex object number (oid + version) */
-static inline __u64 fid_num(const struct lu_fid *fid)
-{
- __u64 f_ver = fid_ver(fid);
- f_ver = f_ver << LUSTRE_FID_VER_SHIFT;
- return f_ver | fid_oid(fid);
-}
-
static inline int fid_seq_is_sane(__u64 seq)
{
return seq != 0;
#define LUSTRE_OPC_MKNODE (1 << 2)
#define LUSTRE_OPC_CREATE (1 << 3)
-struct placement_hint {
+struct lu_placement_hint {
struct qstr *ph_pname;
struct qstr *ph_cname;
int ph_opc;
/* may be later these should be moved into separate fid_ops */
int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
- struct placement_hint *hint);
+ struct lu_placement_hint *hint);
int (*o_fid_delete)(struct obd_export *exp, struct lu_fid *fid);
static inline int obd_fid_alloc(struct obd_export *exp,
struct lu_fid *fid,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
int rc;
ENTRY;
struct md_op_data op_data = { { 0 } };
struct obd_device *obddev = class_exp2obd(sbi->ll_md_exp);
struct ldlm_res_id res_id =
- { .name = {fid_seq(&lli->lli_fid), fid_num(&lli->lli_fid)} };
+ { .name = {fid_seq(&lli->lli_fid),
+ fid_oid(&lli->lli_fid),
+ fid_ver(&lli->lli_fid)} };
ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
ENTRY;
{
return (fid_seq(&llu_i2info(inode)->lli_fid) ==
fid_seq(&llu_i2info(inode)->lli_sbi->ll_root_fid) &&
- fid_num(&llu_i2info(inode)->lli_fid) ==
- fid_num(&llu_i2info(inode)->lli_sbi->ll_root_fid));
+ fid_oid(&llu_i2info(inode)->lli_fid) ==
+ fid_oid(&llu_i2info(inode)->lli_sbi->ll_root_fid));
}
#define LL_SAVE_INTENT(inode, it) \
clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
if (lock->l_resource->lr_name.name[0] != fid_seq(&lli->lli_fid) ||
- lock->l_resource->lr_name.name[1] != fid_num(&lli->lli_fid)) {
- LDLM_ERROR(lock, "data mismatch with ino %llu/%llu",
+ lock->l_resource->lr_name.name[1] != fid_oid(&lli->lli_fid) ||
+ lock->l_resource->lr_name.name[2] != fid_ver(&lli->lli_fid)) {
+ LDLM_ERROR(lock, "data mismatch with ino %llu/%llu/%llu",
(long long)fid_seq(&lli->lli_fid),
- (long long)fid_num(&lli->lli_fid));
+ (long long)fid_oid(&lli->lli_fid),
+ (long long)fid_ver(&lli->lli_fid));
}
if (S_ISDIR(st->st_mode) &&
(bits & MDS_INODELOCK_UPDATE)) {
obddev = sbi->ll_md_exp->exp_obd;
res_id.name[0] = fid_seq(&lli->lli_fid);
- res_id.name[1] = fid_num(&lli->lli_fid);
+ res_id.name[1] = fid_oid(&lli->lli_fid);
+ res_id.name[2] = fid_ver(&lli->lli_fid);
CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
struct intnl_stat *st = llu_i2stat(ino);
struct ldlm_res_id res_id =
{ .name = {fid_seq(&lli->lli_fid),
- fid_num(&lli->lli_fid), LDLM_FLOCK} };
+ fid_oid(&lli->lli_fid),
+ fid_ver(&lli->lli_fid),
+ LDLM_FLOCK} };
struct lustre_handle lockh = {0};
ldlm_policy_data_t flock;
ldlm_mode_t mode = 0;
GOTO(out_request, err);
}
- LASSERT(fid_num(&sbi->ll_root_fid) != 0);
+ LASSERT(fid_is_sane(&sbi->ll_root_fid));
root = llu_iget(fs, &md);
if (!root || IS_ERR(root)) {
struct obd_device *obddev;
struct ldlm_res_id res_id =
{ .name = { fid_seq(ll_inode2fid(inode)),
- fid_num(ll_inode2fid(inode)),
+ fid_oid(ll_inode2fid(inode)),
+ fid_ver(ll_inode2fid(inode)),
LDLM_FLOCK} };
struct lustre_handle lockh = {0};
ldlm_policy_data_t flock;
#include "llite_internal.h"
static int ll_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
int rc;
ENTRY;
RETURN(rc);
}
- LASSERT(fid_seq(fid) != 0 && fid_num(fid) != 0);
+ LASSERT(fid_is_sane(fid));
RETURN(rc);
}
/* allocates passed fid, that is assigns f_num and f_seq to the @fid */
int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
ENTRY;
RETURN(ll_fid_alloc(sbi->ll_md_exp, fid, hint));
/* allocates passed fid, that is assigns f_num and f_seq to the @fid */
int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
ENTRY;
RETURN(ll_fid_alloc(sbi->ll_dt_exp, fid, hint));
/* llite/llite_fid.c*/
int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
- struct placement_hint *hint);
+ struct lu_placement_hint *hint);
int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
- struct placement_hint *hint);
+ struct lu_placement_hint *hint);
ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid);
/* at this point server answers to client's RPC with same fid as
* client generated for creating some inode. So using ->fid1 is
* okay here. */
- LASSERT(fid_num(&md.body->fid1) != 0);
+ LASSERT(fid_is_sane(&md.body->fid1));
*inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md);
if (*inode == NULL || is_bad_inode(*inode)) {
struct list_head *lp;
#endif
- if (fid_num(fid) == 0)
+ if (!fid_is_sane(fid))
return ERR_PTR(-ESTALE);
inode = search_inode_for_lustre(sb, fid, mode);
if (inode == NULL)
break;
- /* DLM locks are taken using version component as well,
- * so we use fid_num() instead of fid_oid(). */
if (lock->l_resource->lr_name.name[0] != fid_seq(ll_inode2fid(inode)) ||
- lock->l_resource->lr_name.name[1] != fid_num(ll_inode2fid(inode))) {
+ lock->l_resource->lr_name.name[1] != fid_oid(ll_inode2fid(inode)) ||
+ lock->l_resource->lr_name.name[2] != fid_ver(ll_inode2fid(inode))) {
LDLM_ERROR(lock, "data mismatch with object "DFID3" (%p)",
PFID3(ll_inode2fid(inode)), inode);
}
icbd.icbd_parent = parent;
/* allocate new fid for child */
- if (it->it_op & IT_CREAT) {
- struct placement_hint hint = { .ph_pname = NULL,
- .ph_cname = &dentry->d_name,
- .ph_opc = LUSTRE_OPC_CREATE };
+ if (it->it_op & IT_CREAT ||
+ (it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) {
+ struct lu_placement_hint hint = { .ph_pname = NULL,
+ .ph_cname = &dentry->d_name,
+ .ph_opc = LUSTRE_OPC_CREATE };
rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data.fid2, &hint);
if (rc) {
static int ll_symlink_generic(struct inode *dir, struct qstr *name,
const char *tgt)
{
- struct placement_hint hint = { .ph_pname = NULL,
- .ph_cname = name,
- .ph_opc = LUSTRE_OPC_SYMLINK };
+ struct lu_placement_hint hint = { .ph_pname = NULL,
+ .ph_cname = name,
+ .ph_opc = LUSTRE_OPC_SYMLINK };
struct ptlrpc_request *request = NULL;
struct ll_sb_info *sbi = ll_i2sbi(dir);
struct dentry *dchild)
{
- struct placement_hint hint = { .ph_pname = NULL,
- .ph_cname = name,
- .ph_opc = LUSTRE_OPC_MKDIR };
+ struct lu_placement_hint hint = { .ph_pname = NULL,
+ .ph_cname = name,
+ .ph_opc = LUSTRE_OPC_MKDIR };
struct ptlrpc_request *request = NULL;
struct ll_sb_info *sbi = ll_i2sbi(dir);
struct md_op_data op_data = { { 0 } };
it->d.lustre.it_data = 0;
}
- LASSERT(fid_num(&body->fid1) != 0);
+ LASSERT(fid_is_sane(&body->fid1));
nid = body->fid1;
it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
LASSERT(it);
- pid = fid_num(&op_data->fid1) != 0 ? &op_data->fid1 : NULL;
- cid = fid_num(&op_data->fid2) != 0 ? &op_data->fid2 : NULL;
+ pid = fid_is_sane(&op_data->fid1) ? &op_data->fid1 : NULL;
+ cid = fid_is_sane(&op_data->fid2) ? &op_data->fid2 : NULL;
i = lmv_fld_lookup(obd, pid);
CDEBUG(D_OTHER, "INTENT LOCK '%s' for '%*s' on "DFID3" -> %d\n",
/* returns number of target where new fid should be allocated using passed @hint
* as input data for making decision. */
static int lmv_placment_policy(struct obd_device *obd,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
struct lmv_obd *lmv = &obd->u.lmv;
ENTRY;
}
static int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
struct obd_device *obd = class_exp2obd(exp);
struct lmv_obd *lmv = &obd->u.lmv;
CDEBUG(D_OTHER, "subobj "DFID3"\n",
PFID3(&mea->mea_ids[i]));
obj->lo_inodes[i].li_fid = mea->mea_ids[i];
- LASSERT(fid_num(&obj->lo_inodes[i].li_fid));
+ LASSERT(fid_is_sane(&obj->lo_inodes[i].li_fid));
}
return obj;
struct lustre_handle *lockh)
{
struct ldlm_res_id res_id =
- { .name = {fid_seq(fid), fid_num(fid)} };
+ { .name = {fid_seq(fid),
+ fid_oid(fid),
+ fid_ver(fid)} };
struct obd_device *obd = class_exp2obd(exp);
int rc;
ENTRY;
int flags, void *opaque)
{
struct ldlm_res_id res_id =
- { .name = {fid_seq(fid), fid_num(fid)} };
+ { .name = {fid_seq(fid),
+ fid_oid(fid),
+ fid_ver(fid)} };
struct obd_device *obd = class_exp2obd(exp);
int rc;
ENTRY;
res_id.name[0] = fid_seq(fid);
- res_id.name[1] = fid_num(fid);
+ res_id.name[1] = fid_oid(fid);
+ res_id.name[2] = fid_ver(fid);
ldlm_change_cbdata(class_exp2obd(exp)->obd_namespace,
&res_id, it, data);
struct ptlrpc_request *req;
struct obd_device *obddev = class_exp2obd(exp);
struct ldlm_res_id res_id =
- { .name = {fid_seq(&op_data->fid1), fid_num(&op_data->fid1)} };
+ { .name = {fid_seq(&op_data->fid1),
+ fid_oid(&op_data->fid1),
+ fid_ver(&op_data->fid1)} };
ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
struct ldlm_request *lockreq;
struct ldlm_intent *lit;
op_data->namelen, op_data->name, PFID3(&op_data->fid1),
ldlm_it2str(it->it_op), it->it_flags);
- if (fid_num(&op_data->fid2) &&
+ if (fid_is_sane(&op_data->fid2) &&
(it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR)) {
/* We could just return 1 immediately, but since we should only
* be called in revalidate_it if we already have a lock, let's
* verify that. */
struct ldlm_res_id res_id = { .name = { fid_seq(&op_data->fid2),
- fid_num(&op_data->fid2) } };
+ fid_oid(&op_data->fid2),
+ fid_ver(&op_data->fid2) } };
struct lustre_handle lockh;
ldlm_policy_data_t policy;
int mode = LCK_CR;
if (rc < 0)
RETURN(rc);
memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh));
- } else if (!fid_num(&op_data->fid2)) {
+ } else if (!fid_is_sane(&op_data->fid2)) {
/* DISP_ENQ_COMPLETE set means there is extra reference on
* request referenced from this intent, saved for subsequent
* lookup. This path is executed when we proceed to this
/* If we were revalidating a fid/name pair, mark the intent in
* case we fail and get called again from lookup */
- if (fid_num(&op_data->fid2)) {
+ if (fid_is_sane(&op_data->fid2)) {
it_set_disposition(it, DISP_ENQ_COMPLETE);
/* Also: did we find the same inode? */
if (memcmp(&op_data->fid2, &mdt_body->fid1, sizeof(op_data->fid2)))
}
static int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
- struct placement_hint *hint)
+ struct lu_placement_hint *hint)
{
struct client_obd *cli = &exp->exp_obd->u.cli;
int rc = 0;
struct ldlm_res_id *name)
{
memset(name, 0, sizeof *name);
- /* we use fid_num() whoch includes also object version instread of raw
- * fid_oid(). */
name->name[0] = fid_seq(f);
- name->name[1] = fid_num(f);
+ name->name[1] = fid_oid(f);
+ name->name[2] = fid_ver(f);
return name;
}
*/
int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name)
{
- return name->name[0] == fid_seq(f) && name->name[1] == fid_num(f);
+ return name->name[0] == fid_seq(f) &&
+ name->name[1] == fid_oid(f) &&
+ name->name[2] == fid_ver(f);
}
/* issues dlm lock on passed @ns, @f stores it lock handle into @lh. */