From eb266ade1e2da5739ed66495755ec2784a5bf74b Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Sat, 15 Jul 2017 17:55:14 +0530 Subject: posix: Needs to reserve disk space to prevent the brick from getting full Problem: Currently there is no option available at posix xlator to save the disk from getting full Solution: Introduce a new option storage.reserve at posix xlator to configure disk threshold.posix xlator spawn a thread to update the disk space status in posix private structure and same flag is checked by every posix fop before start operation.If flag value is 1 then it sets op_errno to ENOSPC and goto out from the fop. BUG: 1471366 Change-Id: I98287cd409860f4c754fc69a332e0521bfb1b67e Signed-off-by: Mohit Agrawal Reviewed-on: https://review.gluster.org/17780 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Jeff Darcy --- xlators/storage/posix/src/posix.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'xlators/storage/posix/src/posix.h') diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index 81158266111..d83e2678572 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -63,6 +63,18 @@ #define GF_UNLINK_TRUE 0x0000000000000001 #define GF_UNLINK_FALSE 0x0000000000000000 +#define DISK_SPACE_CHECK_AND_GOTO(frame, priv, op_ret, op_errno, out) do { \ + if (frame->root->pid >= 0 && priv->disk_space_full) { \ + op_ret = -1; \ + op_errno = ENOSPC; \ + gf_msg_debug ("posix", ENOSPC, \ + "disk space utilization reached limits" \ + " for path %s ", priv->base_path); \ + goto out; \ + } \ + } while (0) + + /** * posix_fd - internal structure common to file and directory fd's */ @@ -167,6 +179,11 @@ struct posix_private { pthread_t health_check; gf_boolean_t health_check_active; + uint32_t disk_threshhold; + uint32_t disk_space_full; + pthread_t disk_space_check; + gf_boolean_t disk_space_check_active; + #ifdef GF_DARWIN_HOST_OS enum { XATTR_NONE = 0, @@ -274,6 +291,8 @@ __posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags, off_t offset, size_t size); void posix_spawn_health_check_thread (xlator_t *this); +void posix_spawn_disk_space_check_thread (xlator_t *this); + void *posix_fsyncer (void *); int posix_get_ancestry (xlator_t *this, inode_t *leaf_inode, -- cgit