}
}
-static int osd_get_lma(struct osd_thread_info *info, struct inode *inode,
- struct dentry *dentry, struct lustre_mdt_attrs *lma)
+static inline int __osd_xattr_get(struct inode *inode, struct dentry *dentry,
+ const char *name, void *buf, int len)
+{
+ dentry->d_inode = inode;
+ return inode->i_op->getxattr(dentry, name, buf, len);
+}
+
+int osd_get_lma(struct osd_thread_info *info, struct inode *inode,
+ struct dentry *dentry, struct lustre_mdt_attrs *lma)
{
int rc;
- dentry->d_inode = inode;
- rc = inode->i_op->getxattr(dentry, XATTR_NAME_LMA, (void *)lma,
- sizeof(*lma));
+ rc = __osd_xattr_get(inode, dentry, XATTR_NAME_LMA, (void *)lma,
+ sizeof(*lma));
if (rc == -ERANGE) {
/* try with old lma size */
rc = inode->i_op->getxattr(dentry, XATTR_NAME_LMA,
return inode;
}
-struct inode *osd_iget_fid(struct osd_thread_info *info, struct osd_device *dev,
- struct osd_inode_id *id, struct lu_fid *fid)
+static struct inode *
+osd_iget_fid(struct osd_thread_info *info, struct osd_device *dev,
+ struct osd_inode_id *id, struct lu_fid *fid)
{
struct lustre_mdt_attrs *lma = &info->oti_mdt_attrs;
struct inode *inode;
GOTO(out, result = 0);
/* Search order: 3. OI files. */
- result = osd_oi_lookup(info, dev, fid, id);
+ result = osd_oi_lookup(info, dev, fid, id, true);
if (result == -ENOENT) {
if (!fid_is_norm(fid) ||
!ldiskfs_test_bit(osd_oi_fid2idx(dev,fid),
}
-/**
- * Helper function to get and fill the buffer with input values.
- */
-static struct lu_buf *osd_buf_get(const struct lu_env *env, void *area, ssize_t len)
-{
- struct lu_buf *buf;
-
- buf = &osd_oti_get(env)->oti_buf;
- buf->lb_buf = area;
- buf->lb_len = len;
- return buf;
-}
-
/*
* Concurrency: shouldn't matter.
*/
* NB: don't need any lock because no contention at this
* early stage */
inode->i_flags |= S_NOCMTIME;
- inode->i_state |= I_LUSTRE_NOSCRUB;
+
+ /* For new created object, it must be consistent,
+ * and it is unnecessary to scrub against it. */
+ ldiskfs_set_inode_state(inode, LDISKFS_STATE_LUSTRE_NOSCRUB);
obj->oo_inode = inode;
result = 0;
} else {
RETURN(0);
}
-/**
- * Helper function for osd_xattr_set()
- */
-static int __osd_xattr_set(const struct lu_env *env, struct dt_object *dt,
- const struct lu_buf *buf, const char *name, int fl)
-{
- struct osd_object *obj = osd_dt_obj(dt);
- struct inode *inode = obj->oo_inode;
- struct osd_thread_info *info = osd_oti_get(env);
- struct dentry *dentry = &info->oti_child_dentry;
- int fs_flags = 0;
- int rc;
-
- LASSERT(dt_object_exists(dt));
- LASSERT(inode->i_op != NULL && inode->i_op->setxattr != NULL);
-
- if (fl & LU_XATTR_REPLACE)
- fs_flags |= XATTR_REPLACE;
-
- if (fl & LU_XATTR_CREATE)
- fs_flags |= XATTR_CREATE;
+static inline int __osd_xattr_set(struct osd_thread_info *info,
+ struct inode *inode, const char *name,
+ const void *buf, int buflen, int fl)
+{
+ struct dentry *dentry = &info->oti_child_dentry;
ll_vfs_dq_init(inode);
- dentry->d_inode = inode;
- rc = inode->i_op->setxattr(dentry, name, buf->lb_buf,
- buf->lb_len, fs_flags);
- return rc;
+ dentry->d_inode = inode;
+ return inode->i_op->setxattr(dentry, name, buf, buflen, fl);
}
/**
static int osd_ea_fid_set(const struct lu_env *env, struct dt_object *dt,
const struct lu_fid *fid)
{
- struct osd_thread_info *info = osd_oti_get(env);
- struct lustre_mdt_attrs *mdt_attrs = &info->oti_mdt_attrs;
+ struct osd_thread_info *info = osd_oti_get(env);
+ struct inode *inode = osd_dt_obj(dt)->oo_inode;
+ struct lustre_mdt_attrs *lma = &info->oti_mdt_attrs;
+ int rc;
- 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);
+ lustre_lma_init(lma, fid);
+ lustre_lma_swab(lma);
+ rc = __osd_xattr_set(info, inode, XATTR_NAME_LMA, lma, sizeof(*lma),
+ XATTR_CREATE);
+ return rc;
}
/**
if (osd_object_auth(env, dt, capa, CAPA_OPC_META_READ))
return -EACCES;
- dentry->d_inode = inode;
- return inode->i_op->getxattr(dentry, name, buf->lb_buf, buf->lb_len);
+ return __osd_xattr_get(inode, dentry, name, buf->lb_buf, buf->lb_len);
}
const struct lu_buf *buf, const char *name, int fl,
struct thandle *handle, struct lustre_capa *capa)
{
+ struct osd_object *obj = osd_dt_obj(dt);
+ struct inode *inode = obj->oo_inode;
+ struct osd_thread_info *info = osd_oti_get(env);
+ int fs_flags = 0;
+
LASSERT(handle != NULL);
/* version set is not real XATTR */
return -EACCES;
osd_trans_exec_op(env, handle, OSD_OT_XATTR_SET);
- return __osd_xattr_set(env, dt, buf, name, fl);
+ if (fl & LU_XATTR_REPLACE)
+ fs_flags |= XATTR_REPLACE;
+
+ if (fl & LU_XATTR_CREATE)
+ fs_flags |= XATTR_CREATE;
+
+ return __osd_xattr_set(info, inode, name, buf->lb_buf, buf->lb_len,
+ fs_flags);
}
/*
LASSERT(dt_object_exists(dt));
LASSERT(inode->i_op != NULL && inode->i_op->removexattr != NULL);
- LASSERT(osd_write_locked(env, obj));
LASSERT(handle != NULL);
if (osd_object_auth(env, dt, capa, CAPA_OPC_META_WRITE))
RETURN_EXIT;
again:
- rc = osd_oi_lookup(oti, dev, fid, id);
+ rc = osd_oi_lookup(oti, dev, fid, id, true);
if (rc != 0 && rc != -ENOENT)
RETURN_EXIT;
GOTO(out, rc = -EINVAL);
}
+ ldiskfs_set_inode_state(osd_sb(o)->s_root->d_inode,
+ LDISKFS_STATE_LUSTRE_NO_OI);
if (lmd_flags & LMD_FLG_NOSCRUB)
o->od_noscrub = 1;