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

Commit d5a7df06 authored by Tao Ma's avatar Tao Ma Committed by Joel Becker
Browse files

ocfs2: Reset xattr value size after xa_cleanup_value_truncate().



In ocfs2_prepare_xattr_entry, if we fail to grow an existing value,
xa_cleanup_value_truncate() will leave the old entry in place.  Thus, we
reset its value size.  However, if we were allocating a new value, we
must not reset the value size or we will BUG().  This resolves
oss.oracle.com bug 1247.

Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent 41841b0b
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -2135,15 +2135,18 @@ static int ocfs2_xa_prepare_entry(struct ocfs2_xa_loc *loc,
		orig_clusters = ocfs2_xa_value_clusters(loc);
		rc = ocfs2_xa_value_truncate(loc, xi->xi_value_len, ctxt);
		if (rc < 0) {
			ocfs2_xa_cleanup_value_truncate(loc, "growing",
							orig_clusters);
			/*
			 * If we tried to grow an existing external value,
			 * ocfs2_xa_cleanuP-value_truncate() is going to
			 * let it stand.  We have to restore its original
			 * value size.
			 * If we were growing an existing value,
			 * ocfs2_xa_cleanup_value_truncate() won't remove
			 * the entry. We need to restore the original value
			 * size.
			 */
			if (loc->xl_entry) {
				BUG_ON(!orig_value_size);
				loc->xl_entry->xe_value_size = orig_value_size;
			ocfs2_xa_cleanup_value_truncate(loc, "growing",
							orig_clusters);
			}
			mlog_errno(rc);
		}
	}