Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e445b6f authored by Tiger Yang's avatar Tiger Yang Committed by Mark Fasheh
Browse files

ocfs2: calculate and reserve credits for xattr value in mknod



We extend the credits for xattr's large value in set_value_outside
before, this can give rise to a credits issue when we set one security
entry and two acl entries duing mknod. As we remove extend_trans form
set_value_outside, we must calculate and reserve the credits for
xattr's large value in mknod.

Signed-off-by: default avatarTiger Yang <tiger.yang@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 90cb546c
Loading
Loading
Loading
Loading
+26 −14
Original line number Original line Diff line number Diff line
@@ -490,9 +490,14 @@ int ocfs2_calc_security_init(struct inode *dir,
	}
	}


	/* reserve clusters for xattr value which will be set in B tree*/
	/* reserve clusters for xattr value which will be set in B tree*/
	if (si->value_len > OCFS2_XATTR_INLINE_SIZE)
	if (si->value_len > OCFS2_XATTR_INLINE_SIZE) {
		*want_clusters += ocfs2_clusters_for_bytes(dir->i_sb,
		int new_clusters = ocfs2_clusters_for_bytes(dir->i_sb,
							    si->value_len);
							    si->value_len);

		*xattr_credits += ocfs2_clusters_to_blocks(dir->i_sb,
							   new_clusters);
		*want_clusters += new_clusters;
	}
	return ret;
	return ret;
}
}


@@ -506,9 +511,7 @@ int ocfs2_calc_xattr_init(struct inode *dir,
{
{
	int ret = 0;
	int ret = 0;
	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
	int s_size = 0;
	int s_size = 0, a_size = 0, acl_len = 0, new_clusters;
	int a_size = 0;
	int acl_len = 0;


	if (si->enable)
	if (si->enable)
		s_size = ocfs2_xattr_entry_real_size(strlen(si->name),
		s_size = ocfs2_xattr_entry_real_size(strlen(si->name),
@@ -556,16 +559,25 @@ int ocfs2_calc_xattr_init(struct inode *dir,
		*xattr_credits += ocfs2_blocks_per_xattr_bucket(dir->i_sb);
		*xattr_credits += ocfs2_blocks_per_xattr_bucket(dir->i_sb);
	}
	}


	/* reserve clusters for xattr value which will be set in B tree*/
	/*
	if (si->enable && si->value_len > OCFS2_XATTR_INLINE_SIZE)
	 * reserve credits and clusters for xattrs which has large value
		*want_clusters += ocfs2_clusters_for_bytes(dir->i_sb,
	 * and have to be set outside
	 */
	if (si->enable && si->value_len > OCFS2_XATTR_INLINE_SIZE) {
		new_clusters = ocfs2_clusters_for_bytes(dir->i_sb,
							si->value_len);
							si->value_len);
		*xattr_credits += ocfs2_clusters_to_blocks(dir->i_sb,
							   new_clusters);
		*want_clusters += new_clusters;
	}
	if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL &&
	if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL &&
	    acl_len > OCFS2_XATTR_INLINE_SIZE) {
	    acl_len > OCFS2_XATTR_INLINE_SIZE) {
		*want_clusters += ocfs2_clusters_for_bytes(dir->i_sb, acl_len);
		/* for directory, it has DEFAULT and ACCESS two types of acls */
		if (S_ISDIR(mode))
		new_clusters = (S_ISDIR(mode) ? 2 : 1) *
			*want_clusters += ocfs2_clusters_for_bytes(dir->i_sb,
				ocfs2_clusters_for_bytes(dir->i_sb, acl_len);
								   acl_len);
		*xattr_credits += ocfs2_clusters_to_blocks(dir->i_sb,
							   new_clusters);
		*want_clusters += new_clusters;
	}
	}


	return ret;
	return ret;