From cff5db814ee31b556d321f7421cdb3fccc8c629d Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Tue, 28 Apr 2015 18:51:38 +0530 Subject: features/shard: Add "is-directory" checks in stat/fstat During mount, NFS directly calls stat on the root of the volume without sending a lookup on it. This was causing inode_ctx_get_block_size() to fail on /. A check is now added in [f]stat which would ensure no action is taken by shard xlator when the operation is on a directory. Change-Id: I81849eeddfdad9f271155442408d95b4a25d7647 BUG: 1207615 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/10427 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Vijay Bellur --- xlators/features/shard/src/shard.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'xlators/features/shard') diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 95d4de09256..4e78b49ee56 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -494,6 +494,12 @@ shard_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) uint64_t block_size = 0; shard_local_t *local = NULL; + if (IA_ISDIR (loc->inode->ia_type)) { + STACK_WIND (frame, default_stat_cbk, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->stat, loc, xdata); + return 0; + } + ret = shard_inode_ctx_get_block_size (loc->inode, this, &block_size); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get block size " @@ -538,6 +544,12 @@ shard_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) uint64_t block_size = 0; shard_local_t *local = NULL; + if (IA_ISDIR (fd->inode->ia_type)) { + STACK_WIND (frame, default_fstat_cbk, FIRST_CHILD(this), + FIRST_CHILD (this)->fops->fstat, fd, xdata); + return 0; + } + ret = shard_inode_ctx_get_block_size (fd->inode, this, &block_size); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get block size " -- cgit