Step 1: Split the matrix into a simple part and a correction.
Write $A = \begin{pmatrix} 2 & 0 & 0 \\ 0 & 2 & 1 \\ 0 & 1 & 2 \end{pmatrix} = 2I + N$, where $N = \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}$. Maximizing $x^TAx$ over unit vectors gives the largest eigenvalue of $A$, a standard Rayleigh quotient fact for symmetric matrices, so it is enough to find the eigenvalues of $N$ and shift them by $2$.
Step 2: Find the eigenvalues of $N$.
$N$ acts with eigenvalue $0$ on the $x_1$ direction, and swaps $x_2$ and $x_3$ through the $2\times 2$ block $\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$. A swap matrix of this size has eigenvalues $1$ and $-1$, with eigenvectors $(1,1)$ and $(1,-1)$. So the eigenvalues of $N$ are $0, 1, -1$.
Step 3: Shift back to get the eigenvalues of $A$.
Since $A = 2I + N$, each eigenvalue of $A$ is $2$ plus the matching eigenvalue of $N$:
\[ 2+0=2, \qquad 2+1=3, \qquad 2+(-1)=1 \]
So the eigenvalues of $A$ are $1, 2, 3$, matching what a direct characteristic polynomial calculation would give.
Step 4: Apply the Rayleigh quotient fact.
Because $x^Tx=1$ restricts $x$ to the unit sphere, the maximum of $x^TAx$ over this constraint equals the largest eigenvalue of $A$, achieved when $x$ is the matching unit eigenvector. The largest eigenvalue found is $3$.
Final Answer:
The maximum value of $z$ is $3$.
\[ \boxed{3} \]