static void osd_object_delete(const struct lu_env *env, struct lu_object *l)
{
struct osd_object *obj = osd_obj(l);
+ struct qsd_instance *qsd = osd_def_qsd(osd_obj2dev(obj));
struct inode *inode = obj->oo_inode;
+ __u64 projid;
+ qid_t uid;
+ qid_t gid;
LINVRNT(osd_invariant(obj));
*/
osd_index_fini(obj);
- if (inode != NULL) {
- struct qsd_instance *qsd = osd_def_qsd(osd_obj2dev(obj));
- qid_t uid = i_uid_read(inode);
- qid_t gid = i_gid_read(inode);
- obj->oo_inode = NULL;
- iput(inode);
- if (!obj->oo_header && qsd) {
- struct osd_thread_info *info = osd_oti_get(env);
- struct lquota_id_info *qi = &info->oti_qi;
+ if (!inode)
+ return;
- /* Release granted quota to master if necessary */
- qi->lqi_id.qid_uid = uid;
- qsd_op_adjust(env, qsd, &qi->lqi_id, USRQUOTA);
+ uid = i_uid_read(inode);
+ gid = i_gid_read(inode);
+ projid = i_projid_read(inode);
- qi->lqi_id.qid_uid = gid;
- qsd_op_adjust(env, qsd, &qi->lqi_id, GRPQUOTA);
+ obj->oo_inode = NULL;
+ iput(inode);
- qi->lqi_id.qid_uid = i_projid_read(inode);
- qsd_op_adjust(env, qsd, &qi->lqi_id, PRJQUOTA);
- }
+ /* do not rebalance quota if the caller needs to release memory
+ * otherwise qsd_refresh_usage() may went into a new ldiskfs
+ * transaction and risk to deadlock - LU-12178 */
+ if (current->flags & (PF_MEMALLOC | PF_KSWAPD))
+ return;
+
+ if (!obj->oo_header && qsd) {
+ struct osd_thread_info *info = osd_oti_get(env);
+ struct lquota_id_info *qi = &info->oti_qi;
+
+ /* Release granted quota to master if necessary */
+ qi->lqi_id.qid_uid = uid;
+ qsd_op_adjust(env, qsd, &qi->lqi_id, USRQUOTA);
+
+ qi->lqi_id.qid_uid = gid;
+ qsd_op_adjust(env, qsd, &qi->lqi_id, GRPQUOTA);
+
+ qi->lqi_id.qid_uid = projid;
+ qsd_op_adjust(env, qsd, &qi->lqi_id, PRJQUOTA);
}
}
#endif
param->ddp_max_ea_size = sb->s_blocksize - ea_overhead;
- if (param->ddp_max_ea_size > OSD_MAX_EA_SIZE)
- param->ddp_max_ea_size = OSD_MAX_EA_SIZE;
+ if (param->ddp_max_ea_size > OBD_MAX_EA_SIZE - ea_overhead)
+ param->ddp_max_ea_size = OBD_MAX_EA_SIZE - ea_overhead;
/*
* Preferred RPC size for efficient disk IO. 4MB shows good
}
}
+static struct super_block *osd_mnt_sb_get(const struct dt_device *d)
+{
+ return osd_sb(osd_dt_dev(d));
+}
+
/*
* Concurrency: shouldn't matter.
*/
.dt_trans_stop = osd_trans_stop,
.dt_trans_cb_add = osd_trans_cb_add,
.dt_conf_get = osd_conf_get,
+ .dt_mnt_sb_get = osd_mnt_sb_get,
.dt_sync = osd_sync,
.dt_ro = osd_ro,
.dt_commit_async = osd_commit_async,
static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj,
umode_t mode, struct dt_allocation_hint *hint,
- struct thandle *th)
+ struct thandle *th, struct lu_attr *attr)
{
int result;
struct osd_device *osd = osd_obj2dev(obj);
struct osd_thandle *oth;
struct dt_object *parent = NULL;
struct inode *inode;
+ uid_t owner[2] = {0, 0};
+
+ if (attr->la_valid & LA_UID)
+ owner[0] = attr->la_uid;
+ if (attr->la_valid & LA_GID)
+ owner[1] = attr->la_gid;
LINVRNT(osd_invariant(obj));
LASSERT(obj->oo_inode == NULL);
inode = ldiskfs_create_inode(oth->ot_handle,
parent ? osd_dt_obj(parent)->oo_inode :
osd_sb(osd)->s_root->d_inode,
- mode);
+ mode, owner);
if (!IS_ERR(inode)) {
/* Do not update file c/mtime in ldiskfs. */
inode->i_flags |= S_NOCMTIME;
oth = container_of(th, struct osd_thandle, ot_super);
LASSERT(oth->ot_handle->h_transaction != NULL);
- result = osd_mkfile(info, obj, mode, hint, th);
+ result = osd_mkfile(info, obj, mode, hint, th, attr);
return result;
}
oth = container_of(th, struct osd_thandle, ot_super);
LASSERT(oth->ot_handle->h_transaction != NULL);
- result = osd_mkfile(info, obj, mode, hint, th);
+ result = osd_mkfile(info, obj, mode, hint, th, attr);
if (result == 0) {
LASSERT(obj->oo_inode != NULL);
if (feat->dif_flags & DT_IND_VARKEY)
{
LASSERT(S_ISREG(attr->la_mode));
return osd_mkfile(info, obj, (attr->la_mode &
- (S_IFMT | S_IALLUGO | S_ISVTX)), hint, th);
+ (S_IFMT | S_IALLUGO | S_ISVTX)), hint, th,
+ attr);
}
static int osd_mksym(struct osd_thread_info *info, struct osd_object *obj,
{
LASSERT(S_ISLNK(attr->la_mode));
return osd_mkfile(info, obj, (attr->la_mode &
- (S_IFMT | S_IALLUGO | S_ISVTX)), hint, th);
+ (S_IFMT | S_IALLUGO | S_ISVTX)), hint, th,
+ attr);
}
static int osd_mknod(struct osd_thread_info *info, struct osd_object *obj,
LASSERT(S_ISCHR(mode) || S_ISBLK(mode) ||
S_ISFIFO(mode) || S_ISSOCK(mode));
- result = osd_mkfile(info, obj, mode, hint, th);
+ result = osd_mkfile(info, obj, mode, hint, th, attr);
if (result == 0) {
LASSERT(obj->oo_inode != NULL);
/*
oh = container_of(th, struct osd_thandle, ot_super);
LASSERT(oh->ot_handle->h_transaction != NULL);
- local = ldiskfs_create_inode(oh->ot_handle, pobj->oo_inode, type);
+ local = ldiskfs_create_inode(oh->ot_handle, pobj->oo_inode, type,
+ NULL);
if (IS_ERR(local)) {
CERROR("%s: create local error %d\n", osd_name(osd),
(int)PTR_ERR(local));
"force_over_512tb",
NULL
};
- strcat(options, opts);
+ strncat(options, opts, PAGE_SIZE);
for (rc = 0, str = options; sout[rc]; ) {
char *op = strstr(str, sout[rc]);
;
}
} else {
- strncat(options, "user_xattr,acl", 14);
+ strncat(options, "user_xattr,acl", PAGE_SIZE);
}
/* Glom up mount options */
if (*options != '\0')
- strcat(options, ",");
- strlcat(options, "no_mbcache,nodelalloc", PAGE_SIZE);
+ strncat(options, ",", PAGE_SIZE);
+ strncat(options, "no_mbcache,nodelalloc", PAGE_SIZE);
type = get_fs_type("ldiskfs");
if (!type) {