struct thandle *handle,
struct lustre_capa *capa)
{
- struct osd_object *obj = osd_dt_obj(dt);
- struct osd_thandle *oh;
- struct iam_path_descr *ipd;
- struct iam_container *bag = &obj->oo_dir->od_container;
- int rc;
+ struct osd_thread_info *oti = osd_oti_get(env);
+ struct osd_object *obj = osd_dt_obj(dt);
+ struct osd_thandle *oh;
+ struct iam_path_descr *ipd;
+ struct iam_container *bag = &obj->oo_dir->od_container;
+ int rc;
ENTRY;
LASSERT(oh->ot_handle != NULL);
LASSERT(oh->ot_handle->h_transaction != NULL);
+ if (fid_is_quota(lu_object_fid(&dt->do_lu))) {
+ /* swab quota uid/gid provided by caller */
+ oti->oti_quota_id = cpu_to_le64(*((__u64 *)key));
+ key = (const struct dt_key *)&oti->oti_quota_id;
+ }
+
rc = iam_delete(oh->ot_handle, bag, (const struct iam_key *)key, ipd);
osd_ipd_put(env, bag, ipd);
LINVRNT(osd_invariant(obj));
/* got ipd now we can start iterator. */
iam_it_init(it, bag, 0, ipd);
+ if (fid_is_quota(lu_object_fid(&dt->do_lu))) {
+ /* swab quota uid/gid provided by caller */
+ oti->oti_quota_id = cpu_to_le64(*((__u64 *)key));
+ key = (const struct dt_key *)&oti->oti_quota_id;
+ }
+
rc = iam_it_get(it, (struct iam_key *)key);
if (rc >= 0) {
if (S_ISDIR(obj->oo_inode->i_mode))
iam_rec = (struct iam_rec *) rec;
iam_reccpy(&it->ii_path.ip_leaf, (struct iam_rec *)iam_rec);
+
if (S_ISDIR(obj->oo_inode->i_mode))
osd_fid_unpack((struct lu_fid *) rec,
(struct osd_fid_pack *)iam_rec);
+ else if (fid_is_quota(lu_object_fid(&dt->do_lu)))
+ osd_quota_unpack(obj, rec);
}
+
iam_it_put(it);
iam_it_fini(it);
osd_ipd_put(env, bag, ipd);
cfs_cap_t save = cfs_curproc_cap_pack();
#endif
struct osd_thread_info *oti = osd_oti_get(env);
- struct iam_rec *iam_rec = (struct iam_rec *)oti->oti_ldp;
+ struct iam_rec *iam_rec;
int rc;
ENTRY;
else
cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
#endif
- if (S_ISDIR(obj->oo_inode->i_mode))
- osd_fid_pack((struct osd_fid_pack *)iam_rec, rec, &oti->oti_fid);
- else
- iam_rec = (struct iam_rec *) rec;
+ if (S_ISDIR(obj->oo_inode->i_mode)) {
+ iam_rec = (struct iam_rec *)oti->oti_ldp;
+ osd_fid_pack((struct osd_fid_pack *)iam_rec, rec, &oti->oti_fid);
+ } else if (fid_is_quota(lu_object_fid(&dt->do_lu))) {
+ /* pack quota uid/gid */
+ oti->oti_quota_id = cpu_to_le64(*((__u64 *)key));
+ key = (const struct dt_key *)&oti->oti_quota_id;
+ /* pack quota record */
+ rec = osd_quota_pack(obj, rec, &oti->oti_quota_rec);
+ iam_rec = (struct iam_rec *)rec;
+ } else {
+ iam_rec = (struct iam_rec *)rec;
+ }
+
rc = iam_insert(oh->ot_handle, bag, (const struct iam_key *)key,
iam_rec, ipd);
#ifdef HAVE_QUOTA_SUPPORT
static int osd_it_iam_get(const struct lu_env *env,
struct dt_it *di, const struct dt_key *key)
{
- struct osd_it_iam *it = (struct osd_it_iam *)di;
+ struct osd_thread_info *oti = osd_oti_get(env);
+ struct osd_it_iam *it = (struct osd_it_iam *)di;
+
+ if (fid_is_quota(lu_object_fid(&it->oi_obj->oo_dt.do_lu))) {
+ /* swab quota uid/gid */
+ oti->oti_quota_id = cpu_to_le64(*((__u64 *)key));
+ key = (struct dt_key *)&oti->oti_quota_id;
+ }
return iam_it_get(&it->oi_it, (const struct iam_key *)key);
}
static struct dt_key *osd_it_iam_key(const struct lu_env *env,
const struct dt_it *di)
{
- struct osd_it_iam *it = (struct osd_it_iam *)di;
+ struct osd_thread_info *oti = osd_oti_get(env);
+ struct osd_it_iam *it = (struct osd_it_iam *)di;
+ struct osd_object *obj = it->oi_obj;
+ struct dt_key *key;
- return (struct dt_key *)iam_it_key_get(&it->oi_it);
+ key = (struct dt_key *)iam_it_key_get(&it->oi_it);
+
+ if (!IS_ERR(key) && fid_is_quota(lu_object_fid(&obj->oo_dt.do_lu))) {
+ /* swab quota uid/gid */
+ oti->oti_quota_id = le64_to_cpu(*((__u64 *)key));
+ key = (struct dt_key *)&oti->oti_quota_id;
+ }
+
+ return key;
}
/**
/* IAM does not store object type in IAM index (dir) */
osd_it_pack_dirent(lde, fid, hash, name, namelen,
0, LUDA_FID);
+ } else if (fid_is_quota(lu_object_fid(&it->oi_obj->oo_dt.do_lu))) {
+ iam_reccpy(&it->oi_it.ii_path.ip_leaf,
+ (struct iam_rec *)dtrec);
+ osd_quota_unpack(it->oi_obj, dtrec);
} else {
iam_reccpy(&it->oi_it.ii_path.ip_leaf,
(struct iam_rec *)dtrec);
}
};
+static inline void osd_quota_swab(char *ptr, size_t size)
+{
+ int offset;
+
+ LASSERT((size & (sizeof(__u64) - 1)) == 0);
+
+ for (offset = 0; offset < size; offset += sizeof(__u64))
+ __swab64s((__u64 *)(ptr + offset));
+}
+
+const struct dt_rec *osd_quota_pack(struct osd_object *obj,
+ const struct dt_rec *rec,
+ union lquota_rec *quota_rec)
+{
+#ifdef __BIG_ENDIAN
+ struct iam_descr *descr;
+
+ LASSERT(obj->oo_dir != NULL);
+ descr = obj->oo_dir->od_container.ic_descr;
+
+ memcpy(quota_rec, rec, descr->id_rec_size);
+
+ osd_quota_swab((char *)quota_rec, descr->id_rec_size);
+ return (const struct dt_rec *)quota_rec;
+#else
+ return rec;
+#endif
+}
+
+void osd_quota_unpack(struct osd_object *obj, const struct dt_rec *rec)
+{
+#ifdef __BIG_ENDIAN
+ struct iam_descr *descr;
+
+ LASSERT(obj->oo_dir != NULL);
+ descr = obj->oo_dir->od_container.ic_descr;
+
+ osd_quota_swab((char *)rec, descr->id_rec_size);
+#else
+ return;
+#endif
+}
+
static inline int osd_qid_type(struct osd_thandle *oh, int i)
{
return (oh->ot_id_type & (1 << i)) ? GRPQUOTA : USRQUOTA;
RETURN(rcu ? rcu : rcg);
}
-