/**
* to protect index ops.
*/
- struct rw_semaphore oo_ext_idx_sem;
- struct rw_semaphore oo_sem;
+ cfs_rw_semaphore_t oo_ext_idx_sem;
+ cfs_rw_semaphore_t oo_sem;
struct osd_directory *oo_dir;
/** protects inode attributes. */
- spinlock_t oo_guard;
+ cfs_spinlock_t oo_guard;
/**
* Following two members are used to indicate the presence of dot and
* dotdot in the given directory. This is required for interop mode
* (b11826).
*/
- int oo_compat_dot_created;
- int oo_compat_dotdot_created;
+ int oo_compat_dot_created;
+ int oo_compat_dotdot_created;
const struct lu_env *oo_owner;
#ifdef CONFIG_LOCKDEP
mo->oo_dt.do_ops = &osd_obj_ops;
l->lo_ops = &osd_lu_obj_ops;
- init_rwsem(&mo->oo_sem);
- init_rwsem(&mo->oo_ext_idx_sem);
- spin_lock_init(&mo->oo_guard);
+ cfs_init_rwsem(&mo->oo_sem);
+ cfs_init_rwsem(&mo->oo_ext_idx_sem);
+ cfs_spin_lock_init(&mo->oo_guard);
return l;
} else
return NULL;
LASSERT(!lu_object_is_dying(l->lo_header));
if (o->oo_inode != NULL && osd_inode_unlinked(o->oo_inode))
- set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
+ cfs_set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
}
/*
* Concurrency: shouldn't matter.
*/
int osd_statfs(const struct lu_env *env, struct dt_device *d,
- struct kstatfs *sfs)
+ cfs_kstatfs_t *sfs)
{
struct osd_device *osd = osd_dt_dev(d);
struct super_block *sb = osd_sb(osd);
int result = 0;
- spin_lock(&osd->od_osfs_lock);
+ cfs_spin_lock(&osd->od_osfs_lock);
/* cache 1 second */
if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) {
result = ll_do_statfs(sb, &osd->od_kstatfs);
if (likely(result == 0))
*sfs = osd->od_kstatfs;
- spin_unlock(&osd->od_osfs_lock);
+ cfs_spin_unlock(&osd->od_osfs_lock);
return result;
}
/**
* Xattr set. The same as xattr of EXT3.
* DATA_TRANS_BLOCKS(14)
- * XXX Note: in original MDS implmentation INDEX_EXTRA_TRANS_BLOCKS are
- * also counted in. Do not know why?
+ * XXX Note: in original MDS implmentation INDEX_EXTRA_TRANS_BLOCKS
+ * are also counted in. Do not know why?
*/
[DTO_XATTR_SET] = 14,
[DTO_LOG_REC] = 14,
[DTO_WRITE_BLOCK] = 14,
/**
* Attr set credits for chown.
- * 3 (inode bit, group, GDT)
+ * This is extra credits for setattr, and it is null without quota
*/
- [DTO_ATTR_SET_CHOWN]= 3
+ [DTO_ATTR_SET_CHOWN]= 0
};
/**
[DTO_WRITE_BLOCK] = 16,
/**
* Attr set credits for chown.
- * 3 (inode bit, group, GDT) +
+ * It is added to already set setattr credits
* 2 * QUOTA_INIT_BLOCKS(25) +
* 2 * QUOTA_DEL_BLOCKS(9)
*/
- [DTO_ATTR_SET_CHOWN]= 71
+ [DTO_ATTR_SET_CHOWN]= 68,
};
static int osd_credit_get(const struct lu_env *env, struct dt_device *d,
LINVRNT(osd_invariant(obj));
LASSERT(obj->oo_owner != env);
- down_read_nested(&obj->oo_sem, role);
+ cfs_down_read_nested(&obj->oo_sem, role);
LASSERT(obj->oo_owner == NULL);
oti->oti_r_locks++;
LINVRNT(osd_invariant(obj));
LASSERT(obj->oo_owner != env);
- down_write_nested(&obj->oo_sem, role);
+ cfs_down_write_nested(&obj->oo_sem, role);
LASSERT(obj->oo_owner == NULL);
obj->oo_owner = env;
LASSERT(oti->oti_r_locks > 0);
oti->oti_r_locks--;
- up_read(&obj->oo_sem);
+ cfs_up_read(&obj->oo_sem);
}
static void osd_object_write_unlock(const struct lu_env *env,
LASSERT(oti->oti_w_locks > 0);
oti->oti_w_locks--;
obj->oo_owner = NULL;
- up_write(&obj->oo_sem);
+ cfs_up_write(&obj->oo_sem);
}
static int osd_object_write_locked(const struct lu_env *env,
RETURN(-ESTALE);
}
- spin_lock(&capa_lock);
+ cfs_spin_lock(&capa_lock);
for (i = 0; i < 2; i++) {
if (keys[i].lk_keyid == capa->lc_keyid) {
oti->oti_capa_key = keys[i];
break;
}
}
- spin_unlock(&capa_lock);
+ cfs_spin_unlock(&capa_lock);
if (i == 2) {
DEBUG_CAPA(D_ERROR, capa, "no matched capa key");
if (osd_object_auth(env, dt, capa, CAPA_OPC_META_READ))
return -EACCES;
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
osd_inode_getattr(env, obj->oo_inode, attr);
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
return 0;
}
i_size_write(inode, attr->la_size);
}
+#if 0
/* OSD should not change "i_blocks" which is used by quota.
- * "i_blocks" should be changed by ldiskfs only.
- * Enable this assignment for SOM purpose now, until it is
- * stored in SOM EA. */
+ * "i_blocks" should be changed by ldiskfs only. */
if (bits & LA_BLOCKS)
inode->i_blocks = attr->la_blocks;
-
+#endif
if (bits & LA_MODE)
inode->i_mode = (inode->i_mode & S_IFMT) |
(attr->la_mode & ~S_IFMT);
if (osd_object_auth(env, dt, capa, CAPA_OPC_META_WRITE))
return -EACCES;
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
rc = osd_inode_setattr(env, obj->oo_inode, attr);
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
if (!rc)
mark_inode_dirty(obj->oo_inode);
static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj,
- umode_t mode,
+ cfs_umode_t mode,
struct dt_allocation_hint *hint,
struct thandle *th)
{
struct dt_object_format *dof,
struct thandle *th)
{
- umode_t mode = attr->la_mode & (S_IFMT | S_IRWXUGO | S_ISVTX);
+ cfs_umode_t mode = attr->la_mode & (S_IFMT | S_IRWXUGO | S_ISVTX);
int result;
LINVRNT(osd_invariant(obj));
static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah,
- struct dt_object *parent, umode_t child_mode)
+ struct dt_object *parent, cfs_umode_t child_mode)
{
LASSERT(ah);
rc = inode->i_op->setxattr(dentry, name, buf->lb_buf,
buf->lb_len, fs_flags);
/* ctime should not be updated with server-side time. */
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
inode->i_ctime = *t;
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
mark_inode_dirty(inode);
return rc;
}
struct osd_thread_info *info = osd_oti_get(env);
struct lustre_mdt_attrs *mdt_attrs = &info->oti_mdt_attrs;
- fid_cpu_to_be(&mdt_attrs->lma_self_fid, fid);
-
+ 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);
* Try to read the fid from inode ea into dt_rec, if return value
* i.e. rc is +ve, then we got fid, otherwise we will have to form igif
*
- * \param fid, object fid.
+ * \param fid object fid.
*
- * \retval 0, on success
+ * \retval 0 on success
*/
static int osd_ea_fid_get(const struct lu_env *env, struct osd_object *obj,
__u32 ino, struct lu_fid *fid)
/* Check LMA compatibility */
if (rc > 0 &&
- (mdt_attrs->lma_incompat & ~cpu_to_be32(LMA_INCOMPAT_SUPP))) {
+ (mdt_attrs->lma_incompat & ~cpu_to_le32(LMA_INCOMPAT_SUPP))) {
CWARN("Inode %lx: Unsupported incompat LMA feature(s) %#x\n",
- inode->i_ino, be32_to_cpu(mdt_attrs->lma_incompat) &
+ inode->i_ino, le32_to_cpu(mdt_attrs->lma_incompat) &
~LMA_INCOMPAT_SUPP);
return -ENOSYS;
}
if (rc > 0) {
- fid_be_to_cpu(fid, &mdt_attrs->lma_self_fid);
+ lustre_lma_swab(mdt_attrs);
+ memcpy(fid, &mdt_attrs->lma_self_fid, sizeof(*fid));
rc = 0;
} else if (rc == -ENODATA) {
osd_igif_get(env, inode, fid);
LASSERT(osd_write_locked(env, obj));
LASSERT(th != NULL);
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
LASSERT(inode->i_nlink < LDISKFS_LINK_MAX);
inode->i_nlink++;
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
mark_inode_dirty(inode);
LINVRNT(osd_invariant(obj));
}
LASSERT(osd_write_locked(env, obj));
LASSERT(th != NULL);
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
LASSERT(inode->i_nlink > 0);
inode->i_nlink--;
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
mark_inode_dirty(inode);
LINVRNT(osd_invariant(obj));
}
*t = inode->i_ctime;
rc = inode->i_op->removexattr(dentry, name);
/* ctime should not be updated with server-side time. */
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
inode->i_ctime = *t;
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
mark_inode_dirty(inode);
return rc;
}
__u32 d[4], s[4];
s[0] = obj->oo_inode->i_uid;
- get_random_bytes(&(s[1]), sizeof(__u32));
+ ll_get_random_bytes(&(s[1]), sizeof(__u32));
s[2] = obj->oo_inode->i_gid;
- get_random_bytes(&(s[3]), sizeof(__u32));
+ ll_get_random_bytes(&(s[3]), sizeof(__u32));
rc = capa_encrypt_id(d, s, key->lk_key, CAPA_HMAC_KEY_MAX_LEN);
if (unlikely(rc))
RETURN(ERR_PTR(rc));
RETURN(oc);
}
- spin_lock(&capa_lock);
+ cfs_spin_lock(&capa_lock);
*key = dev->od_capa_keys[1];
- spin_unlock(&capa_lock);
+ cfs_spin_unlock(&capa_lock);
capa->lc_keyid = key->lk_keyid;
capa->lc_expiry = cfs_time_current_sec() + dev->od_capa_timeout;
OBD_ALLOC_PTR(dir);
if (dir != NULL) {
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
if (obj->oo_dir == NULL)
obj->oo_dir = dir;
else
* Concurrent thread allocated container data.
*/
OBD_FREE_PTR(dir);
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
/*
* Now, that we have container data, serialize its
* initialization.
*/
- down_write(&obj->oo_ext_idx_sem);
+ cfs_down_write(&obj->oo_ext_idx_sem);
/*
* recheck under lock.
*/
result = osd_iam_container_init(env, obj, dir);
else
result = 0;
- up_write(&obj->oo_ext_idx_sem);
+ cfs_up_write(&obj->oo_ext_idx_sem);
} else
result = -ENOMEM;
} else
/**
* delete a (key, value) pair from index \a dt specified by \a key
*
- * \param dt_object osd index object
+ * \param dt osd index object
* \param key key for index
* \param rec record reference
* \param handle transaction handler
dentry = osd_child_dentry_get(env, obj,
(char *)key, strlen((char *)key));
- down_write(&obj->oo_ext_idx_sem);
- bh = ldiskfs_find_entry(dentry, &de);
+ cfs_down_write(&obj->oo_ext_idx_sem);
+ bh = ll_ldiskfs_find_entry(dir, dentry, &de);
if (bh) {
struct osd_thread_info *oti = osd_oti_get(env);
struct timespec *ctime = &oti->oti_time;
rc = ldiskfs_delete_entry(oh->ot_handle,
dir, de, bh);
/* xtime should not be updated with server-side time. */
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
dir->i_ctime = *ctime;
dir->i_mtime = *mtime;
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
mark_inode_dirty(dir);
brelse(bh);
} else
rc = -ENOENT;
- up_write(&obj->oo_ext_idx_sem);
+ cfs_up_write(&obj->oo_ext_idx_sem);
LASSERT(osd_invariant(obj));
RETURN(rc);
}
/**
* Lookup index for \a key and copy record to \a rec.
*
- * \param dt_object osd index object
+ * \param dt osd index object
* \param key key for index
* \param rec record reference
*
dentry = osd_child_dentry_get(env, obj,
(char *)key, strlen((char *)key));
- down_read(&obj->oo_ext_idx_sem);
- bh = ldiskfs_find_entry(dentry, &de);
+ cfs_down_read(&obj->oo_ext_idx_sem);
+ bh = ll_ldiskfs_find_entry(dir, dentry, &de);
if (bh) {
ino = le32_to_cpu(de->inode);
brelse(bh);
} else
rc = -ENOENT;
- up_read(&obj->oo_ext_idx_sem);
+ cfs_up_read(&obj->oo_ext_idx_sem);
RETURN (rc);
}
/**
* Find the osd object for given fid.
*
- * \param fid, need to find the osd object having this fid
+ * \param fid need to find the osd object having this fid
*
- * \retval osd_object, on success
- * \retval -ve, on error
+ * \retval osd_object on success
+ * \retval -ve on error
*/
struct osd_object *osd_object_find(const struct lu_env *env,
struct dt_object *dt,
/**
* Put the osd object once done with it.
*
- * \param obj, osd object that needs to be put
+ * \param obj osd object that needs to be put
*/
static inline void osd_object_put(const struct lu_env *env,
struct osd_object *obj)
* It will add the directory entry.This entry is needed to
* maintain name->fid mapping.
*
- * \param key, it is key i.e. file entry to be inserted
- * \param rec, it is value of given key i.e. fid
+ * \param key it is key i.e. file entry to be inserted
+ * \param rec it is value of given key i.e. fid
*
* \retval 0, on success
* \retval -ve, on error
else
current->cap_effective &= ~CFS_CAP_SYS_RESOURCE_MASK;
#endif
- down_write(&obj->oo_ext_idx_sem);
+ cfs_down_write(&obj->oo_ext_idx_sem);
rc = osd_ea_add_rec(env, obj, child, name, th);
- up_write(&obj->oo_ext_idx_sem);
+ cfs_up_write(&obj->oo_ext_idx_sem);
#ifdef HAVE_QUOTA_SUPPORT
current->cap_effective = save;
#endif
osd_object_put(env, child);
/* xtime should not be updated with server-side time. */
- spin_lock(&obj->oo_guard);
+ cfs_spin_lock(&obj->oo_guard);
inode->i_ctime = *ctime;
inode->i_mtime = *mtime;
- spin_unlock(&obj->oo_guard);
+ cfs_spin_unlock(&obj->oo_guard);
mark_inode_dirty(inode);
} else {
rc = PTR_ERR(child);
/**
* Destroy or finishes iterator context.
*
- * \param di, struct osd_it_ea, iterator structure to be destroyed
+ * \param di iterator structure to be destroyed
*/
static void osd_it_ea_fini(const struct lu_env *env, struct dt_it *di)
{
* iterator's in-memory data structure with required
* information i.e. name, namelen, rec_size etc.
*
- * \param buf, in which information to be filled in.
- * \param name, name of the file in given dir
+ * \param buf in which information to be filled in.
+ * \param name name of the file in given dir
*
- * \retval 0, on success
- * \retval 1, on buffer full
+ * \retval 0 on success
+ * \retval 1 on buffer full
*/
static int osd_ldiskfs_filldir(char *buf, const char *name, int namelen,
loff_t offset, __u64 ino,
memcpy(ent->oied_name, name, namelen);
it->oie_rd_dirent++;
- it->oie_dirent = (void *) ent + size_round(sizeof(*ent) + namelen);
+ it->oie_dirent = (void *) ent + cfs_size_round(sizeof(*ent) + namelen);
RETURN(0);
}
* Calls ->readdir() to load a directory entry at a time
* and stored it in iterator's in-memory data structure.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
*
- * \retval 0, on success
- * \retval -ve, on error
+ * \retval 0 on success
+ * \retval -ve on error
*/
static int osd_ldiskfs_it_fill(const struct dt_it *di)
{
it->oie_dirent = it->oie_buf;
it->oie_rd_dirent = 0;
- down_read(&obj->oo_ext_idx_sem);
+ cfs_down_read(&obj->oo_ext_idx_sem);
result = inode->i_fop->readdir(&it->oie_file, it,
(filldir_t) osd_ldiskfs_filldir);
- up_read(&obj->oo_ext_idx_sem);
+ cfs_up_read(&obj->oo_ext_idx_sem);
if (it->oie_rd_dirent == 0) {
result = -EIO;
* to load a directory entry at a time and stored it in
* iterator's in-memory data structure.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
*
- * \retval +ve, iterator reached to end
- * \retval 0, iterator not reached to end
- * \retval -ve, on error
+ * \retval +ve iterator reached to end
+ * \retval 0 iterator not reached to end
+ * \retval -ve on error
*/
static int osd_it_ea_next(const struct lu_env *env, struct dt_it *di)
{
ENTRY;
if (it->oie_it_dirent < it->oie_rd_dirent) {
- it->oie_dirent = (void *) it->oie_dirent +
- size_round(sizeof(struct osd_it_ea_dirent) +
- it->oie_dirent->oied_namelen);
+ it->oie_dirent =
+ (void *) it->oie_dirent +
+ cfs_size_round(sizeof(struct osd_it_ea_dirent) +
+ it->oie_dirent->oied_namelen);
it->oie_it_dirent++;
RETURN(0);
} else {
/**
* Returns the key at current position from iterator's in memory structure.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
*
* \retval key i.e. struct dt_key on success
*/
/**
* Returns the key's size at current position from iterator's in memory structure.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
*
* \retval key_size i.e. struct dt_key on success
*/
* Returns the value (i.e. fid/igif) at current position from iterator's
* in memory structure.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
- * \param attr, attr requested for dirent.
- * \param lde, lustre dirent
+ * \param di struct osd_it_ea, iterator's in memory structure
+ * \param attr attr requested for dirent.
+ * \param lde lustre dirent
*
- * \retval 0, no error and \param lde has correct lustre dirent.
- * \retval -ve, on error
+ * \retval 0 no error and \param lde has correct lustre dirent.
+ * \retval -ve on error
*/
static inline int osd_it_ea_rec(const struct lu_env *env,
const struct dt_it *di,
* Returns a cookie for current position of the iterator head, so that
* user can use this cookie to load/start the iterator next time.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di iterator's in memory structure
*
* \retval cookie for current position, on success
*/
* to load a directory entry at a time and stored it i inn,
* in iterator's in-memory data structure.
*
- * \param di, struct osd_it_ea, iterator's in memory structure
+ * \param di struct osd_it_ea, iterator's in memory structure
*
- * \retval +ve, on success
- * \retval -ve, on error
+ * \retval +ve on success
+ * \retval -ve on error
*/
static int osd_it_ea_load(const struct lu_env *env,
const struct dt_it *di, __u64 hash)
l = osd2lu_dev(o);
l->ld_ops = &osd_lu_ops;
o->od_dt_dev.dd_ops = &osd_dt_ops;
- spin_lock_init(&o->od_osfs_lock);
+ cfs_spin_lock_init(&o->od_osfs_lock);
o->od_osfs_age = cfs_time_shift_64(-1000);
o->od_capa_hash = init_capa_hash();
if (o->od_capa_hash == NULL) {
static int osd_recovery_complete(const struct lu_env *env,
struct lu_device *d)
{
- struct osd_device *o = osd_dev(d);
- ENTRY;
- /* TODO: orphans handling */
- ldiskfs_orphan_cleanup(osd_sb(o), LDISKFS_SB(osd_sb(o))->s_es);
RETURN(0);
}