From 5a29779aceec59069511cec7eff9b314e819eacc Mon Sep 17 00:00:00 2001 From: Shreyas Siravara Date: Thu, 7 Sep 2017 16:36:29 -0700 Subject: storage/posix: Add limit to number of hard links Summary: Too may hard links blow up btrfs by exceeding max xattr size (recordign pgfid for each hardlink). Add a limit to prevent this explosion. > Reviewed-on: https://review.gluster.org/18232 > Reviewed-by: Shreyas Siravara Fixes gluster/glusterfs#370 Signed-off-by: ShyamsundarR Change-Id: I614a247834fb8f2b2743c0c67d11cefafff0dbaa --- xlators/storage/posix/src/posix-entry-ops.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'xlators/storage/posix/src/posix-entry-ops.c') diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index 7a83eb3dfba..e7658e46543 100644 --- a/xlators/storage/posix/src/posix-entry-ops.c +++ b/xlators/storage/posix/src/posix-entry-ops.c @@ -1814,6 +1814,15 @@ posix_link (call_frame_t *frame, xlator_t *this, goto out; } + if (priv->max_hardlinks && stbuf.ia_nlink >= priv->max_hardlinks) { + op_ret = -1; + op_errno = EMLINK; + gf_log (this->name, GF_LOG_ERROR, + "hardlink failed: %s exceeds max link count (%u/%u).", + real_oldpath, stbuf.ia_nlink, priv->max_hardlinks); + goto out; + } + MAKE_ENTRY_HANDLE (real_newpath, par_newpath, this, newloc, &stbuf); if (!real_newpath || !par_newpath) { op_ret = -1; -- cgit