Use SA_HDL_PRIVATE for SA xattrs
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 2 Mar 2012 18:35:50 +0000 (10:35 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 2 Mar 2012 21:20:48 +0000 (13:20 -0800)
commitec2626ad3f695a2ced3946c4197ef64cbcac4959
tree9efe62507581fdef859b06390413ebda57632d43
parent4b787d75c869a7f633607ecb17f3a7c482a553d2
Use SA_HDL_PRIVATE for SA xattrs

A private SA handle must be used to ensure we can drop the dbuf
hold on the spill block prior to calling dmu_tx_commit().  If we
call dmu_tx_commit() before sa_handle_destroy(), then our hold
will trigger a copy of the dbuf to be made.  This is done to
prevent data from leaking in to the syncing txg.  As a result
the original dirty spill block will remain cached.

Additionally, relying on the shared zp->z_sa_hdl is unsafe in
the xattr context because the znode may be asynchronously dropped
from the cache.  It's far safer and simpler just to use a private
handle for xattrs.  Plus any additional overhead is offset by
the avoidance of the previously mentioned memory copy.

These forever dirty buffers can be noticed in the arcstats under
the anon_size.  On a quiescent system the value should be zero.
Without this fix and a SA xattr write workload you will see
anon_size increase.  Eventually, if enough dirty data builds up
your system it will appear to hang.  This occurs because the dmu
won't allow new txs to be assigned until that dirty data is
flushed, and it won't be because it's not part of an assigned tx.

As an aside, I typically see anon_size lurk around 16k so I think
there is another place in the code which needs a similar fix.
However, this value doesn't grow over time so it isn't critical.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #503
Issue #513
module/zfs/zfs_sa.c