summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-entry-ops.c
diff options
context:
space:
mode:
authorShreyas Siravara <sshreyas@fb.com>2017-09-07 16:36:29 -0700
committerKrutika Dhananjay <kdhananj@redhat.com>2017-12-08 09:07:35 +0000
commit5a29779aceec59069511cec7eff9b314e819eacc (patch)
treef2641d7f453eb3e770942b2fda3a654c23f169d8 /xlators/storage/posix/src/posix-entry-ops.c
parent97a97bab57873083d5b49f636fd0ccbe94a310e3 (diff)
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 <sshreyas@fb.com> Fixes gluster/glusterfs#370 Signed-off-by: ShyamsundarR <srangana@redhat.com> Change-Id: I614a247834fb8f2b2743c0c67d11cefafff0dbaa
Diffstat (limited to 'xlators/storage/posix/src/posix-entry-ops.c')
-rw-r--r--xlators/storage/posix/src/posix-entry-ops.c9
1 files changed, 9 insertions, 0 deletions
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;