void
__shard_update_shards_inode_list (inode_t *linked_inode, xlator_t *this,
                                  inode_t *base_inode, int block_num)
{
        char                block_bname[256] = {0,};
        inode_t            *lru_inode        = NULL;
        shard_priv_t       *priv             = NULL;
        shard_inode_ctx_t  *ctx              = NULL;
        shard_inode_ctx_t  *lru_inode_ctx    = NULL;

        priv = this->private;

        shard_inode_ctx_get (linked_inode, this, &ctx);

        gf_msg (this->name, GF_LOG_ERROR, 0, SHARD_MSG_SIZE_SET_FAILED,
                        "block_num to be added = %d ",block_num);
        if (list_empty (&ctx->ilist)) {
                if (priv->inode_count + 1 <= SHARD_MAX_INODES) {
                /* If this inode was linked here for the first time (indicated
                 * by empty list), and if there is still space in the priv list,
                 * add this ctx to the tail of the list.
                 */
                        gf_msg (this->name, GF_LOG_ERROR, 0, SHARD_MSG_SIZE_SET_FAILED,
                        "block_num %d add to tail of list, base_inode gfis = %s , inode_count = %d",
                        block_num, uuid_utoa(base_inode->gfid), priv->inode_count);
                        gf_uuid_copy (ctx->base_gfid, base_inode->gfid);
                        ctx->block_num = block_num;
                        list_add_tail (&ctx->ilist, &priv->ilist_head);
                        priv->inode_count++;
                } else {
                /*If on the other hand there is no available slot for this inode
                 * in the list, delete the lru inode from the head of the list,
                 * unlink it. And in its place add this new inode into the list.
                 */
                        lru_inode_ctx = list_first_entry (&priv->ilist_head,
                                                          shard_inode_ctx_t,
                                                          ilist);
                        gf_msg (this->name, GF_LOG_ERROR, 0, SHARD_MSG_SIZE_SET_FAILED,
                        "block_num to be purged = %d, base_gfid =  %s stat.ia_gfid = %s",
                        lru_inode_ctx->block_num, uuid_utoa(lru_inode_ctx->base_gfid), uuid_utoa(lru_inode_ctx->stat.ia_gfid));
                        GF_ASSERT (lru_inode_ctx->block_num > 0);
                        list_del_init (&lru_inode_ctx->ilist);
                        lru_inode = inode_find (linked_inode->table,
                                                lru_inode_ctx->stat.ia_gfid);
                        shard_make_block_bname (lru_inode_ctx->block_num,
                                                lru_inode_ctx->base_gfid,
                                                block_bname,
                                                sizeof (block_bname));
                        inode_unlink (lru_inode, priv->dot_shard_inode,
                                      block_bname);
                        /* The following unref corresponds to the ref held by
                         * inode_find() above.
                         */
                        inode_forget (lru_inode, 0);
                        inode_unref (lru_inode);
                        gf_uuid_copy (ctx->base_gfid, base_inode->gfid);
                        ctx->block_num = block_num;
                        list_add_tail (&ctx->ilist, &priv->ilist_head);
                }
        } else {
         /* If this is not the first time this inode is being operated on, move
         * it to the most recently used end of the list.
         */
                list_move_tail (&ctx->ilist, &priv->ilist_head);
        }
}
