Skip to content

Instantly share code, notes, and snippets.

View harshavardhana's full-sized avatar
🌚
I may be slow to respond.

Harshavardhana harshavardhana

🌚
I may be slow to respond.
View GitHub Profile
@harshavardhana
harshavardhana / timecreatefile.py
Last active December 23, 2015 09:48
Script to test XFS open()/creat() delays
#!/usr/bin/env python2
#
# Usage:
# $ cd <xfs_brick>; strace -c python2 /tmp/timecreatefile.py
import os
import timeit
filename = 'foo'
@harshavardhana
harshavardhana / btrace.gdb
Created September 19, 2013 21:34
Batch script gdb for backtrace
set logging file <BACKTRACE_FILE>
set logging on
set pagination off
thread apply all bt full
@harshavardhana
harshavardhana / smb_glusterfs_vfs.c
Created September 20, 2013 00:10
Samba VFS GlusterFS plugin OOM reproducer
#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
@harshavardhana
harshavardhana / encrypt_crypt_test.sh
Created September 20, 2013 00:49
Script to generate soft lockups in kernel
#!/bin/bash
########################################################################
# This bash script will encypt backups using an unmodified version of
# Cryptsetup.
#
# Usage:
#
# $ dd if=/dev/zero of=/DS02/test/<backup_file> bs=1M count=<count>
#
# $ encrypt_stress {iteration} {size} {loopdevice} {backup_file}
@harshavardhana
harshavardhana / gfid_to_file.sh
Last active December 24, 2015 04:59
GlusterFS GFID to File conversion based on inode number
#!/bin/bash
BRICK=/path/to/brick
for i in $(grep 'split-brain' /var/log/glusterfs/glustershd.log | awk {'print $11'} | sort | uniq); do
GFID=$(echo $i | cut -f2 -d: | cut -f1 -d'>')
INODE=$(ls -i ${BRICK}/.glusterfs/${GFID:0:2}/${GFID:2:2}/${GFID} | awk {'print $1'})
FILES=$(find ${BRICK} -inum ${INODE})
echo ${BRICK}/.glusterfs/${GFID:0:2}/${GFID:2:2}/${GFID}
echo ${FILES}
done
@harshavardhana
harshavardhana / dirstream.c
Created October 7, 2013 03:43
Closedir dirstream corruption check during directory crawling
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#define _FILE_OFFSET_BITS 64
int main()
{
package main
import (
"path/filepath"
"os"
"flag"
"fmt"
)
type fileattr struct {
@harshavardhana
harshavardhana / dircmp.go
Created October 15, 2013 22:55
Directory compare
package main
import (
"path/filepath"
"os"
"flag"
"fmt"
)
type fileattr struct {
@harshavardhana
harshavardhana / rebalance_large_files.sh
Last active August 29, 2015 14:00
rebalance_large_files
#!/bin/bash
list_large_files_checksum ()
{
local DIR=$1;
large_files=""
large_directories=""
# Get top ten culprit files
for i in $(du --exclude=".glusterfs" -akx $DIR | sort -nr | head -10 | awk {'print $2'}); do
if [ -f $i ]; then
@harshavardhana
harshavardhana / json_verify.pl
Created May 4, 2014 01:32
Json parse validate
#!/usr/bin/env perl
# Borrowed from - http://search.cpan.org/~mlehmann/JSON-XS-3.01/bin/json_xs
# Modified for internal use in GlusterFS
use strict;
use Encode;
use JSON::XS;
my $opt_from = "json";
my $opt_to = "null";