};
extern void lustre_swab_quota_adjust_qunit(struct quota_adjust_qunit *q);
-/* flags is shared among quota structures */
+/* flags in qunit_data and quota_adjust_qunit will use macroes below */
#define LQUOTA_FLAGS_GRP 1UL /* 0 is user, 1 is group */
#define LQUOTA_FLAGS_BLK 2UL /* 0 is inode, 1 is block */
#define LQUOTA_FLAGS_ADJBLK 4UL /* adjust the block qunit size */
#define LQUOTA_FLAGS_CHG_QS 16UL /* indicate whether it has capability of
* OBD_CONNECT_CHANGE_QS */
-/* flags is specific for quota_adjust_qunit */
-#define LQUOTA_QAQ_CEATE_LQS (1 << 31) /* when it is set, need create lqs */
-
-/* the status of lqs_flags in struct lustre_qunit_size */
+/* the status of lqsk_flags in struct lustre_qunit_size_key */
#define LQUOTA_QUNIT_FLAGS (LQUOTA_FLAGS_GRP | LQUOTA_FLAGS_BLK)
-#define QAQ_IS_GRP(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_GRP)
-#define QAQ_IS_ADJBLK(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJBLK)
-#define QAQ_IS_ADJINO(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJINO)
-#define QAQ_IS_CREATE_LQS(qaq) ((qaq)->qaq_flags & LQUOTA_QAQ_CEATE_LQS)
+#define QAQ_IS_GRP(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_GRP)
+#define QAQ_IS_ADJBLK(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJBLK)
+#define QAQ_IS_ADJINO(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJINO)
-#define QAQ_SET_GRP(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_GRP)
-#define QAQ_SET_ADJBLK(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJBLK)
-#define QAQ_SET_ADJINO(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJINO)
-#define QAQ_SET_CREATE_LQS(qaq) ((qaq)->qaq_flags |= LQUOTA_QAQ_CEATE_LQS)
+#define QAQ_SET_GRP(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_GRP)
+#define QAQ_SET_ADJBLK(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJBLK)
+#define QAQ_SET_ADJINO(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJINO)
/* inode access permission for remote user, the inode info are omitted,
* for client knows them. */
RETURN(rc);
}
-static int mdd_append_attrs(const struct lu_env *env,
- struct mdd_device *mdd,
- __u32 attr,
- const struct dt_it_ops *iops,
- struct dt_it *it,
- struct lu_dirent*ent)
-{
- struct mdd_thread_info *info = mdd_env_info(env);
- struct lu_fid *fid = &info->mti_fid2;
- int len = cpu_to_le16(ent->lde_namelen);
- const unsigned align = sizeof(struct luda_type) - 1;
- struct lu_fid_pack *pack;
- struct mdd_object *obj;
- struct luda_type *lt;
- int rc = 0;
-
- if (attr & LUDA_FID) {
- pack = (struct lu_fid_pack *)iops->rec(env, it);
- if (IS_ERR(pack)) {
- rc = PTR_ERR(pack);
- ent->lde_attrs = 0;
- goto out;
- }
- rc = fid_unpack(pack, fid);
- if (rc != 0) {
- ent->lde_attrs = 0;
- goto out;
- }
-
- fid_cpu_to_le(&ent->lde_fid, fid);
- ent->lde_attrs = LUDA_FID;
- }
-
- /* check if file type is required */
- if (attr & LUDA_TYPE) {
- if (!(attr & LUDA_FID)) {
- CERROR("wrong attr : [%x]\n",attr);
- rc = -EINVAL;
- goto out;
- }
-
- obj = mdd_object_find(env, mdd, fid);
- if (obj == NULL) /* remote object */
- goto out;
-
- if (IS_ERR(obj)) {
- rc = PTR_ERR(obj);
- goto out;
- }
-
- if (mdd_object_exists(obj) == +1) {
- len = (len + align) & ~align;
-
- lt = (void *) ent->lde_name + len;
- lt->lt_type = cpu_to_le16(mdd_object_type(obj));
-
- ent->lde_attrs |= LUDA_TYPE;
- }
- mdd_object_put(env, obj);
- }
-out:
- ent->lde_attrs = cpu_to_le32(ent->lde_attrs);
- return rc;
-}
-
static int mdd_dir_page_build(const struct lu_env *env, struct mdd_device *mdd,
int first, void *area, int nob,
const struct dt_it_ops *iops, struct dt_it *it,
struct lu_dirent **last, __u32 attr)
{
int result;
+ __u64 hash = 0;
struct lu_dirent *ent;
- __u64 hash = 0;
if (first) {
memset(area, 0, sizeof (struct lu_dirpage));
ent = area;
do {
- char *name;
int len;
int recsize;
if (len == 0)
goto next;
- name = (char *)iops->key(env, it);
hash = iops->store(env, it);
-
if (unlikely(first)) {
first = 0;
*start = hash;
}
+ /* calculate max space required for lu_dirent */
recsize = lu_dirent_calc_size(len, attr);
- CDEBUG(D_INFO, "%p %p %d "LPU64" (%d) \"%*.*s\"\n",
- name, ent, nob, hash, len, len, len, name);
-
if (nob >= recsize) {
- ent->lde_hash = cpu_to_le64(hash);
- ent->lde_namelen = cpu_to_le16(len);
- ent->lde_reclen = cpu_to_le16(recsize);
- memcpy(ent->lde_name, name, len);
-
- result = mdd_append_attrs(env, mdd, attr, iops, it, ent);
+ result = iops->rec(env, it, ent, attr);
if (result == -ESTALE)
goto next;
if (result != 0)
goto out;
+
+ /* osd might not able to pack all attributes,
+ * so recheck rec length */
+ recsize = le16_to_cpu(ent->lde_reclen);
} else {
/*
* record doesn't fit into page, enlarge previous one.
rc = iops->load(env, it, rdpg->rp_hash);
- if (rc == 0)
+ if (rc == 0){
/*
* Iterator didn't find record with exactly the key requested.
*
* state)---position it on the next item.
*/
rc = iops->next(env, it);
- else if (rc > 0)
+ } else if (rc > 0)
rc = 0;
/*
struct lustre_capa *capa);
static struct dt_key *osd_it_iam_key (const struct lu_env *env,
const struct dt_it *di);
-static struct dt_rec *osd_it_iam_rec (const struct lu_env *env,
- const struct dt_it *di);
+static int osd_it_iam_rec (const struct lu_env *env,
+ const struct dt_it *di,
+ struct lu_dirent *lde,
+ __u32 attr);
static struct dt_it *osd_it_ea_init (const struct lu_env *env,
struct dt_object *dt,
struct lustre_capa *capa);
static struct dt_key *osd_it_ea_key (const struct lu_env *env,
const struct dt_it *di);
-static struct dt_rec *osd_it_ea_rec (const struct lu_env *env,
- const struct dt_it *di);
+static inline int osd_it_ea_rec (const struct lu_env *env,
+ const struct dt_it *di,
+ struct lu_dirent *lde,
+ __u32 attr);
static struct timespec *osd_inode_time (const struct lu_env *env,
struct inode *inode,
* Helper function to pack the fid
*/
static inline void osd_fid_pack(const struct lu_env *env, const struct lu_fid *fid,
- struct lu_fid_pack *pack)
+ struct dt_rec *pack)
{
- fid_pack(pack, fid, &osd_oti_get(env)->oti_fid);
+ fid_pack((struct lu_fid_pack *)pack, fid, &osd_oti_get(env)->oti_fid);
}
/**
* 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 rec, the data-structure into which fid/igif is read
+ * \param fid, object fid.
*
* \retval 0, on success
*/
static int osd_ea_fid_get(const struct lu_env *env, struct dentry *dentry,
- struct dt_rec *rec)
+ struct lu_fid *fid)
{
struct inode *inode = dentry->d_inode;
struct osd_thread_info *info = osd_oti_get(env);
struct lustre_mdt_attrs *mdt_attrs = &info->oti_mdt_attrs;
- struct lu_fid *fid = &info->oti_fid;
int rc;
LASSERT(inode->i_op != NULL && inode->i_op->getxattr != NULL);
rc = 0;
}
- if (rc == 0)
- osd_fid_pack(env, fid, (struct lu_fid_pack*)rec);
-
return rc;
}
struct osd_inode_id *id = &info->oti_id;
struct ldiskfs_dir_entry_2 *de;
struct buffer_head *bh;
+ struct lu_fid * fid = &info->oti_fid;
struct inode *inode;
int ino;
int rc;
if (!IS_ERR(inode)) {
dentry->d_inode = inode;
- rc = osd_ea_fid_get(env, dentry, rec);
+ rc = osd_ea_fid_get(env, dentry, fid);
+ if (rc == 0)
+ osd_fid_pack(env, fid, rec);
+
iput(inode);
} else
rc = PTR_ERR(inode);
return iam_it_key_size(&it->oi_it);
}
+static inline void osd_it_append_attrs(struct lu_dirent*ent,
+ __u32 attr,
+ int len,
+ __u16 type)
+{
+ struct luda_type *lt;
+ const unsigned align = sizeof(struct luda_type) - 1;
+
+ /* check if file type is required */
+ if (attr & LUDA_TYPE) {
+ len = (len + align) & ~align;
+
+ lt = (void *) ent->lde_name + len;
+ lt->lt_type = cpu_to_le16(CFS_DTTOIF(type));
+ ent->lde_attrs |= LUDA_TYPE;
+ }
+
+ ent->lde_attrs = cpu_to_le32(ent->lde_attrs);
+}
+
+/**
+ * build lu direct from backend fs dirent.
+ */
+
+static inline void osd_it_pack_dirent(struct lu_dirent *ent,
+ struct lu_fid *fid,
+ __u64 offset,
+ char *name,
+ __u16 namelen,
+ __u16 type,
+ __u32 attr)
+{
+ fid_cpu_to_le(&ent->lde_fid, fid);
+ ent->lde_attrs = LUDA_FID;
+
+ ent->lde_hash = cpu_to_le64(offset);
+ ent->lde_reclen = cpu_to_le16(lu_dirent_calc_size(namelen, attr));
+
+ strncpy(ent->lde_name, name, namelen);
+ ent->lde_namelen = cpu_to_le16(namelen);
+
+ /* append lustre attributes */
+ osd_it_append_attrs(ent, attr, namelen, type);
+}
+
/**
* Return pointer to the record under iterator.
*/
-static struct dt_rec *osd_it_iam_rec(const struct lu_env *env,
- const struct dt_it *di)
+static int osd_it_iam_rec(const struct lu_env *env,
+ const struct dt_it *di,
+ struct lu_dirent *lde,
+ __u32 attr)
{
- struct osd_it_iam *it = (struct osd_it_iam *)di;
+ struct osd_it_iam *it = (struct osd_it_iam *)di;
+ struct osd_thread_info *info = osd_oti_get(env);
+ struct lu_fid *fid = &info->oti_fid;
+ const struct lu_fid_pack *rec;
+ char *name;
+ int namelen;
+ __u64 hash;
+ int rc;
+
+ name = (char *)iam_it_key_get(&it->oi_it);
+ if (IS_ERR(name))
+ RETURN(PTR_ERR(name));
+
+ namelen = iam_it_key_size(&it->oi_it);
+
+ rec = (const struct lu_fid_pack *) iam_it_rec_get(&it->oi_it);
+ if (IS_ERR(rec))
+ RETURN(PTR_ERR(rec));
+
+ rc = fid_unpack(rec, fid);
+ if (rc)
+ RETURN(rc);
+
+ hash = iam_it_store(&it->oi_it);
- return (struct dt_rec *)iam_it_rec_get(&it->oi_it);
+ /* IAM does not store object type in IAM index (dir) */
+ osd_it_pack_dirent(lde, fid, hash, name, namelen,
+ 0, LUDA_FID);
+
+ return 0;
}
/**
ent->oied_ino = ino;
ent->oied_off = offset;
ent->oied_namelen = namelen;
+ ent->oied_type = d_type;
+
memcpy(ent->oied_name, name, namelen);
it->oie_rd_dirent++;
RETURN(it->oie_dirent->oied_namelen);
}
+
/**
* 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
*
- * \retval value i.e. struct dt_rec on success
+ * \retval 0, no error and \param lde has correct lustre dirent.
+ * \retval -ve, on error
*/
-static struct dt_rec *osd_it_ea_rec(const struct lu_env *env,
- const struct dt_it *di)
+static inline int osd_it_ea_rec(const struct lu_env *env,
+ const struct dt_it *di,
+ struct lu_dirent *lde,
+ __u32 attr)
{
struct osd_it_ea *it = (struct osd_it_ea *)di;
struct osd_object *obj = it->oie_obj;
struct osd_thread_info *info = osd_oti_get(env);
struct osd_inode_id *id = &info->oti_id;
- struct lu_fid_pack *rec = &info->oti_pack;
struct lu_device *ldev = obj->oo_dt.do_lu.lo_dev;
struct dentry *dentry = &info->oti_child_dentry;
struct osd_device *dev;
+ struct lu_fid *fid = &info->oti_fid;
struct inode *inode;
int rc;
dentry->d_inode = inode;
LASSERT(dentry->d_inode->i_sb == osd_sb(dev));
} else {
- RETURN((struct dt_rec *) PTR_ERR(inode));
+ RETURN(PTR_ERR(inode));
}
- rc = osd_ea_fid_get(env, dentry, (struct dt_rec*) rec);
- if (rc != 0)
- rec = ERR_PTR(rc);
+ rc = osd_ea_fid_get(env, dentry, fid);
+ if (rc == 0)
+ osd_it_pack_dirent(lde, fid, it->oie_dirent->oied_off,
+ it->oie_dirent->oied_name,
+ it->oie_dirent->oied_namelen,
+ it->oie_dirent->oied_type,
+ attr);
iput(inode);
- RETURN((struct dt_rec *)rec);
-
+ RETURN(rc);
}
/**